x12 billing work and Claim class to psr2/4 work (#1004)
[openemr.git] / sql / 5_0_0-to-5_0_1_upgrade.sql
blob5170edb4abc2d283efbdb1206588bb2d5529bc2a
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
132 #IfNotTable therapy_groups
133 CREATE TABLE `therapy_groups` (
134   `group_id` int(11) NOT NULL auto_increment,
135   `group_name` varchar(255) NOT NULL ,
136   `group_start_date` date NOT NULL ,
137   `group_end_date` date,
138   `group_type` tinyint NOT NULL,
139   `group_participation` tinyint NOT NULL,
140   `group_status` int(11) NOT NULL,
141   `group_notes` text,
142   `group_guest_counselors` varchar(255),
143   PRIMARY KEY  (`group_id`)
144 ) ENGINE=InnoDB;
145 #EndIf
147 #IfNotTable therapy_groups_participants
148 CREATE TABLE `therapy_groups_participants` (
149   `group_id` int(11) NOT NULL,
150   `pid` int(11) NOT NULL ,
151   `group_patient_status` int(11) NOT NULL,
152   `group_patient_start` date NOT NULL ,
153   `group_patient_end` date,
154   `group_patient_comment` text,
155   PRIMARY KEY (`group_id`,`pid`)
156 ) ENGINE=InnoDB;
157 #EndIf
159 #IfNotTable therapy_groups_participant_attendance
160 CREATE TABLE `therapy_groups_participant_attendance` (
161   `form_id` int(11) NOT NULL,
162   `pid` int(11) NOT NULL ,
163   `meeting_patient_comment` text ,
164   `meeting_patient_status` varchar(15),
165   PRIMARY KEY (`form_id`,`pid`)
166 ) ENGINE=InnoDB;
167 #EndIf
169 #IfNotTable therapy_groups_counselors
170 CREATE TABLE `therapy_groups_counselors`(
171         `group_id` int(11) NOT NULL,
172         `user_id` int(11) NOT NULL,
173         PRIMARY KEY (`group_id`,`user_id`)
174 ) ENGINE=InnoDB;
175 #EndIf
177 #IfMissingColumn openemr_postcalendar_events pc_gid
178 ALTER TABLE openemr_postcalendar_events ADD pc_gid int(11) DEFAULT 0;
179 #EndIf
181 #IfNotRow2D list_options list_id lists option_id groupstat
182 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`) VALUES ('lists', 'groupstat', 'Group Statuses', '13', '0', '0');
183 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`) VALUES ('groupstat', '-', '- None', '10', '0', '0', 'FEFDCF|0');
184 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`) VALUES ('groupstat', '=', '= Took Place', '20', '0', '0', 'FF2414|0');
185 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');
186 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `notes`) VALUES ('groupstat', '<', '< Not Reported', '40', '0', '0', 'FEFDCF|0');
187 #EndIf
189 #IfNotRow openemr_postcalendar_categories pc_catname Group Therapy
190 INSERT INTO openemr_postcalendar_categories (`pc_catname`, `pc_catcolor`, `pc_recurrspec`, `pc_duration` ,`pc_cattype` , `pc_active` , `pc_seq`)
191 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');
192 #EndIf
195 #IfNotTable form_groups_encounter
196 CREATE TABLE `form_groups_encounter` (
197   `id` bigint(20) NOT NULL auto_increment,
198   `date` datetime default NULL,
199   `reason` longtext,
200   `facility` longtext,
201   `facility_id` int(11) NOT NULL default '0',
202   `group_id` bigint(20) default NULL,
203   `encounter` bigint(20) default NULL,
204   `onset_date` datetime default NULL,
205   `sensitivity` varchar(30) default NULL,
206   `billing_note` text,
207   `pc_catid` int(11) NOT NULL default '5' COMMENT 'event category from openemr_postcalendar_categories',
208   `last_level_billed` int  NOT NULL DEFAULT 0 COMMENT '0=none, 1=ins1, 2=ins2, etc',
209   `last_level_closed` int  NOT NULL DEFAULT 0 COMMENT '0=none, 1=ins1, 2=ins2, etc',
210   `last_stmt_date`    date DEFAULT NULL,
211   `stmt_count`        int  NOT NULL DEFAULT 0,
212   `provider_id` INT(11) DEFAULT '0' COMMENT 'default and main provider for this visit',
213   `supervisor_id` INT(11) DEFAULT '0' COMMENT 'supervising provider, if any, for this visit',
214   `invoice_refno` varchar(31) NOT NULL DEFAULT '',
215   `referral_source` varchar(31) NOT NULL DEFAULT '',
216   `billing_facility` INT(11) NOT NULL DEFAULT 0,
217   `external_id` VARCHAR(20) DEFAULT NULL,
218   `pos_code` tinyint(4) default NULL,
219   `counselors` VARCHAR (255),
220   `appt_id` INT(11) default NULL,
221   PRIMARY KEY  (`id`),
222   KEY `pid_encounter` (`group_id`, `encounter`),
223   KEY `encounter_date` (`date`)
224 ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
225 #EndIf
227 #IfMissingColumn forms therapy_group_id
228 ALTER TABLE  `forms` ADD  `therapy_group_id` INT(11) DEFAULT NULL;
229 #EndIf
231 #IfMissingColumn registry patient_encounter
232 ALTER TABLE `registry` ADD `patient_encounter` TINYINT NOT NULL DEFAULT '1';
233 #EndIf
235 #IfMissingColumn registry therapy_group_encounter
236 ALTER TABLE `registry` ADD `therapy_group_encounter` TINYINT NOT NULL DEFAULT '0';
237 #EndIf
240 #IfNotRow2D list_options list_id lists option_id attendstat
241 INSERT INTO list_options (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`) VALUES ('lists', 'attendstat', 'Group Attendance Statuses', '15', '0', '0');
242 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');
243 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');
244 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');
245 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');
246 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');
247 #EndIf
249 #IfNotRow registry directory group_attendance
250 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);
251 #EndIf
253 #IfNotRow registry directory newGroupEncounter
254 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);
255 #EndIf
257 #IfNotTable form_therapy_groups_attendance
258 CREATE TABLE `form_therapy_groups_attendance` (
259   id    bigint(20) auto_increment,
260   date  date,
261   group_id      int(11),
262   user  varchar(255),
263   groupname     varchar(255),
264   authorized    tinyint(4),
265   encounter_id  int(11),
266   activity      tinyint(4),
267   PRIMARY KEY (`id`)
268 ) ENGINE=InnoDB ;
269 #EndIf
271 #IfNotRow2D list_options list_id lists option_id files_white_list
272 INSERT INTO list_options (`list_id`, `option_id`, `title`) VALUES ('lists', 'files_white_list', 'Files type white list');
273 #EndIf
275 #IfNotTable onsite_documents
276 CREATE TABLE `onsite_documents` (
277   `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
278   `pid` int(10) UNSIGNED DEFAULT NULL,
279   `facility` int(10) UNSIGNED DEFAULT NULL,
280   `provider` int(10) UNSIGNED DEFAULT NULL,
281   `encounter` int(10) UNSIGNED DEFAULT NULL,
282   `create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
283   `doc_type` varchar(255) NOT NULL,
284   `patient_signed_status` smallint(5) UNSIGNED NOT NULL,
285   `patient_signed_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
286   `authorize_signed_time` datetime DEFAULT NULL,
287   `accept_signed_status` smallint(5) NOT NULL,
288   `authorizing_signator` varchar(50) NOT NULL,
289   `review_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
290   `denial_reason` varchar(255) NOT NULL,
291   `authorized_signature` text,
292   `patient_signature` text,
293   `full_document` blob,
294   `file_name` varchar(255) NOT NULL,
295   `file_path` varchar(255) NOT NULL,
296   PRIMARY KEY (`id`)
297 ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
298 #EndIf
300 #IfNotTable onsite_mail
301 CREATE TABLE `onsite_mail` (
302   `id` bigint(20) NOT NULL AUTO_INCREMENT,
303   `date` datetime DEFAULT NULL,
304   `owner` bigint(20) DEFAULT NULL,
305   `user` varchar(255) DEFAULT NULL,
306   `groupname` varchar(255) DEFAULT NULL,
307   `activity` tinyint(4) DEFAULT NULL,
308   `authorized` tinyint(4) DEFAULT NULL,
309   `header` varchar(255) DEFAULT NULL,
310   `title` varchar(255) DEFAULT NULL,
311   `body` longtext,
312   `recipient_id` varchar(128) DEFAULT NULL,
313   `recipient_name` varchar(255) DEFAULT NULL,
314   `sender_id` varchar(128) DEFAULT NULL,
315   `sender_name` varchar(255) DEFAULT NULL,
316   `assigned_to` varchar(255) DEFAULT NULL,
317   `deleted` tinyint(4) DEFAULT '0' COMMENT 'flag indicates note is deleted',
318   `delete_date` datetime DEFAULT NULL,
319   `mtype` varchar(128) DEFAULT NULL,
320   `message_status` varchar(20) NOT NULL DEFAULT 'New',
321   `mail_chain` int(11) DEFAULT NULL,
322   `reply_mail_chain` int(11) DEFAULT NULL,
323   `is_msg_encrypted` tinyint(2) DEFAULT '0' COMMENT 'Whether messsage encrypted 0-Not encrypted, 1-Encrypted',
324   PRIMARY KEY (`id`),
325   KEY `pid` (`owner`)
326 ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
327 #EndIf
329 #IfNotTable onsite_messages
330 CREATE TABLE `onsite_messages` (
331   `id` int(11) NOT NULL AUTO_INCREMENT,
332   `username` varchar(64) NOT NULL,
333   `message` longtext,
334   `ip` varchar(15) NOT NULL,
335   `date` datetime NOT NULL,
336   `sender_id` int(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'who sent id',
337  `recip_id` varchar(255) NOT NULL COMMENT 'who to id array',
338   PRIMARY KEY (`id`)
339 ) ENGINE=InnoDB COMMENT='Portal messages' AUTO_INCREMENT=1 ;
340 #EndIf
342 #IfNotTable onsite_online
343 CREATE TABLE `onsite_online` (
344   `hash` varchar(32) NOT NULL,
345   `ip` varchar(15) NOT NULL,
346   `last_update` datetime NOT NULL,
347   `username` varchar(64) NOT NULL,
348   `userid` int(11) UNSIGNED DEFAULT NULL,
349   PRIMARY KEY (`hash`)
350 ) ENGINE=InnoDB;
351 #EndIf
353 #IfNotTable onsite_portal_activity
354 CREATE TABLE `onsite_portal_activity` (
355   `id` bigint(20) NOT NULL AUTO_INCREMENT,
356   `date` datetime DEFAULT NULL,
357   `patient_id` bigint(20) DEFAULT NULL,
358   `activity` varchar(255) DEFAULT NULL,
359   `require_audit` tinyint(1) DEFAULT '1',
360   `pending_action` varchar(255) DEFAULT NULL,
361   `action_taken` varchar(255) DEFAULT NULL,
362   `status` varchar(255) DEFAULT NULL,
363   `narrative` longtext,
364   `table_action` longtext,
365   `table_args` longtext,
366   `action_user` int(11) DEFAULT NULL,
367   `action_taken_time` datetime DEFAULT NULL,
368   `checksum` longtext,
369   PRIMARY KEY (`id`),
370   KEY `date` (`date`)
371 ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
372 #EndIf
374 #IfNotTable onsite_signatures
375 CREATE TABLE `onsite_signatures` (
376   `id` bigint(20) NOT NULL AUTO_INCREMENT,
377   `status` varchar(128) NOT NULL DEFAULT 'waiting',
378   `type` varchar(128) NOT NULL,
379   `created` int(11) NOT NULL,
380   `lastmod` datetime NOT NULL,
381   `pid` bigint(20) DEFAULT NULL,
382   `encounter` int(11) DEFAULT NULL,
383   `user` varchar(255) DEFAULT NULL,
384   `activity` tinyint(4) NOT NULL DEFAULT '0',
385   `authorized` tinyint(4) DEFAULT NULL,
386   `signator` varchar(255) NOT NULL,
387   `sig_image` text,
388   `signature` text,
389   `sig_hash` varchar(128) NOT NULL,
390   `ip` varchar(46) NOT NULL,
391   PRIMARY KEY (`id`),
392   UNIQUE KEY `pid` (`pid`,`user`),
393   KEY `encounter` (`encounter`)
394 ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
395 #EndIf
397 #IfNotRow categories name Onsite Portal
398 INSERT INTO categories select (select MAX(id) from categories) + 1, 'Onsite Portal', '', 1, rght, rght + 5 from categories where name = 'Categories';
399 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';
400 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';
401 UPDATE categories SET rght = rght + 6 WHERE name = 'Categories';
402 UPDATE categories_seq SET id = (select MAX(id) from categories);
403 #EndIf
405 #IfNotRow2D list_options list_id apptstat option_id ^
406 INSERT INTO list_options ( `list_id`, `option_id`, `title`, `seq`, `is_default`, `notes` ) VALUES ('apptstat','^','^ Pending',70,0,'FEFDCF|0');
407 #EndIf
409 #IfMissingColumn registry aco_spec
410 ALTER TABLE `registry` ADD `aco_spec` varchar(63) NOT NULL default 'encounters|notes';
411 UPDATE `registry` SET `aco_spec` = 'patients|appt'     WHERE directory = 'newpatient';
412 UPDATE `registry` SET `aco_spec` = 'patients|appt'     WHERE directory = 'newGroupEncounter';
413 UPDATE `registry` SET `aco_spec` = 'encounters|coding' WHERE directory = 'fee_sheet';
414 UPDATE `registry` SET `aco_spec` = 'encounters|coding' WHERE directory = 'misc_billing_options';
415 UPDATE `registry` SET `aco_spec` = 'patients|lab'      WHERE directory = 'procedure_order';
416 #EndIf
418 #IfNotColumnType lbf_data field_value longtext
419 ALTER TABLE `lbf_data` CHANGE `field_value` `field_value` longtext;
420 #EndIf
422 #IfMissingColumn issue_types aco_spec
423 ALTER TABLE `issue_types` ADD `aco_spec` varchar(63) NOT NULL default 'patients|med';
424 #EndIf
426 #IfMissingColumn categories aco_spec
427 ALTER TABLE `categories` ADD `aco_spec` varchar(63) NOT NULL default 'patients|docs';
428 #EndIf
430 #IfNotRow background_services name ccdaservice
431 INSERT INTO `background_services` (`name`, `title`, `execute_interval`, `function`, `require_once`, `sort_order`) VALUES ('ccdaservice', 'C-CDA Node Service', 1, 'runCheck', '/ccdaservice/ssmanager.php', 95);
432 ALTER TABLE `background_services` CHANGE `running` `running` TINYINT(1) NOT NULL DEFAULT '-1' COMMENT 'True indicates managed service is busy. Skip this interval.';
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 #IfNotRow4D supported_external_dataloads load_type ICD10 load_source CMS load_release_date 2017-10-01 load_filename 2018-ICD-10-Code-Dedcriptions.zip 
502 INSERT INTO `supported_external_dataloads` (`load_type`, `load_source`, `load_release_date`, `load_filename`, `load_checksum`) VALUES
503 ('ICD10', 'CMS', '2017-10-01', '2018-ICD-10-Code-Dedcriptions.zip', '6f9c77440132e30f565222ca9bb6599c');
504 #EndIf
506 #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
507 INSERT INTO `supported_external_dataloads` (`load_type`, `load_source`, `load_release_date`, `load_filename`, `load_checksum`) VALUES
508 ('ICD10', 'CMS', '2017-10-01', '2018-ICD-10-PCS-General-Equivalence-Mappings.zip', 'bb73c80e272da28712887d7979b1cebf');
509 #EndIf
511 #IfColumn x12_partners x12_version
512 ALTER TABLE `x12_partners` DROP COLUMN `x12_version`;
513 #EndIf