Security fixes.
[openemr.git] / sql / 2_9_0-to-3_0_0_upgrade.sql
blob8dd2f7790a6560ec94db504487c1ac22cf58bfea
1 #IfMissingColumn form_misc_billing_options replacement_claim
2 ALTER TABLE form_misc_billing_options
3   ADD replacement_claim tinyint(1) DEFAULT 0;
4 #EndIf
6 #IfMissingColumn insurance_data accept_assignment
7 ALTER TABLE insurance_data
8   ADD accept_assignment varchar(5) NOT NULL DEFAULT 'TRUE';
9 #EndIf
11 #IfMissingColumn forms deleted
12 ALTER TABLE forms 
13     ADD deleted TINYINT DEFAULT '0' NOT NULL COMMENT 'flag indicates form has been deleted';
14 #EndIf
16 #IfMissingColumn immunizations vis_date
17 ALTER TABLE immunizations
18   ADD `vis_date` date default NULL COMMENT 'Date of VIS Statement',
19   ADD `administered_by` VARCHAR( 255 ) default NULL COMMENT 'Alternative to administered_by_id';
20 #EndIf
22 #IfNotTable chart_tracker
23 CREATE TABLE chart_tracker (
24   ct_pid            int(11)       NOT NULL,
25   ct_when           datetime      NOT NULL,
26   ct_userid         bigint(20)    NOT NULL DEFAULT 0,
27   ct_location       varchar(31)   NOT NULL DEFAULT '',
28   PRIMARY KEY (ct_pid, ct_when)
29 ) ENGINE=MyISAM;
30 #EndIf
32 #IfNotRow list_options list_id chartloc
33 INSERT INTO list_options VALUES ('lists'   ,'chartloc','Chart Storage Locations',1,0,0);
34 INSERT INTO list_options VALUES ('chartloc','fileroom','File Room'              ,1,0,0);
35 #EndIf
37 #IfMissingColumn form_encounter last_level_billed
38 ALTER TABLE form_encounter
39   ADD last_level_billed int           NOT NULL DEFAULT 0 COMMENT '0=none, 1=ins1, 2=ins2, etc',
40   ADD last_level_closed int           NOT NULL DEFAULT 0 COMMENT '0=none, 1=ins1, 2=ins2, etc',
41   ADD last_stmt_date    date          DEFAULT NULL,
42   ADD stmt_count        int           NOT NULL DEFAULT 0;
43 #EndIf
45 #IfNotTable ar_session
46 CREATE TABLE ar_session (
47   session_id     int unsigned  NOT NULL AUTO_INCREMENT,
48   payer_id       int(11)       NOT NULL            COMMENT '0=pt else references insurance_companies.id',
49   user_id        int(11)       NOT NULL            COMMENT 'references users.id for session owner',
50   closed         tinyint(1)    NOT NULL DEFAULT 0  COMMENT '0=no, 1=yes',
51   reference      varchar(255)  NOT NULL DEFAULT '' COMMENT 'check or EOB number',
52   check_date     date          DEFAULT NULL,
53   deposit_date   date          DEFAULT NULL,
54   pay_total      decimal(12,2) NOT NULL DEFAULT 0,
55   PRIMARY KEY (session_id),
56   KEY user_closed (user_id, closed),
57   KEY deposit_date (deposit_date)
58 ) ENGINE=MyISAM;
59 #EndIf
61 #IfNotTable ar_activity
62 CREATE TABLE ar_activity (
63   pid            int(11)       NOT NULL,
64   encounter      int(11)       NOT NULL,
65   sequence_no    int unsigned  NOT NULL AUTO_INCREMENT,
66   code           varchar(9)    NOT NULL            COMMENT 'empty means claim level',
67   modifier       varchar(5)    NOT NULL DEFAULT '',
68   payer_type     int           NOT NULL            COMMENT '0=pt, 1=ins1, 2=ins2, etc',
69   post_time      datetime      NOT NULL,
70   post_user      int(11)       NOT NULL            COMMENT 'references users.id',
71   session_id     int unsigned  NOT NULL            COMMENT 'references ar_session.session_id',
72   memo           varchar(255)  NOT NULL DEFAULT '' COMMENT 'adjustment reasons go here',
73   pay_amount     decimal(12,2) NOT NULL DEFAULT 0  COMMENT 'either pay or adj will always be 0',
74   adj_amount     decimal(12,2) NOT NULL DEFAULT 0,
75   PRIMARY KEY (pid, encounter, sequence_no),
76   KEY session_id (session_id)
77 ) ENGINE=MyISAM;
78 #EndIf
80 #IfMissingColumn users ssi_relayhealth
81 ALTER TABLE users
82   ADD ssi_relayhealth varchar(64) NULL;
83 #EndIf
85 update layout_options set group_name = concat('1', substring(group_name, 2)) where group_name like 'a%';
86 update layout_options set group_name = concat('2', substring(group_name, 2)) where group_name like 'b%';
87 update layout_options set group_name = concat('3', substring(group_name, 2)) where group_name like 'c%';
88 update layout_options set group_name = concat('4', substring(group_name, 2)) where group_name like 'd%';
89 update layout_options set group_name = concat('5', substring(group_name, 2)) where group_name like 'e%';
90 update layout_options set group_name = concat('6', substring(group_name, 2)) where group_name like 'f%';
91 update layout_options set group_name = concat('7', substring(group_name, 2)) where group_name like 'g%';