2 -- Comment Meta Language Constructs:
5 -- argument: table_name
6 -- behavior: if the table_name does not exist, the block will be executed
9 -- argument: table_name
10 -- behavior: if the table_name does exist, the block will be executed
13 -- arguments: table_name colname
14 -- behavior: if the colname in the table_name table does not exist, the block will be executed
17 -- arguments: table_name colname value
18 -- behavior: If the table table_name does not have a column colname with a data type equal to value, then the block will be executed
21 -- arguments: table_name colname value
22 -- behavior: If the table table_name does not have a row where colname = value, the block will be executed.
25 -- arguments: table_name colname value colname2 value2
26 -- behavior: If the table table_name does not have a row where colname = value AND colname2 = value2, the block will be executed.
29 -- arguments: table_name colname value colname2 value2 colname3 value3
30 -- behavior: If the table table_name does not have a row where colname = value AND colname2 = value2 AND colname3 = value3, the block will be executed.
33 -- arguments: table_name colname value colname2 value2 colname3 value3 colname4 value4
34 -- behavior: If the table table_name does not have a row where colname = value AND colname2 = value2 AND colname3 = value3 AND colname4 = value4, the block will be executed.
37 -- desc: This is a very specialized function to allow adding items to the list_options table to avoid both redundant option_id and title in each element.
38 -- arguments: table_name colname value colname2 value2 colname3 value3
39 -- behavior: The block will be executed if both statements below are true:
40 -- 1) The table table_name does not have a row where colname = value AND colname2 = value2.
41 -- 2) The table table_name does not have a row where colname = value AND colname3 = value3.
44 -- desc: This function will allow adding of indexes/keys.
45 -- arguments: table_name colname
46 -- behavior: If the index does not exist, it will be created
49 -- all blocks are terminated with and #EndIf statement.
52 #IfNotIndex lists type
53 CREATE INDEX `type` ON `lists` (`type`);
57 CREATE INDEX `pid` ON `lists` (`pid`);
60 #IfNotIndex form_vitals pid
61 CREATE INDEX `pid` ON `form_vitals` (`pid`);
65 CREATE INDEX `pid` ON `forms` (`pid`);
68 #IfNotIndex form_encounter pid
69 CREATE INDEX `pid` ON `form_encounter` (`pid`);
72 #IfNotIndex immunizations patient_id
73 CREATE INDEX `patient_id` ON `immunizations` (`patient_id`);
76 #IfNotIndex procedure_order patient_id
77 CREATE INDEX `patient_id` ON `procedure_order` (`patient_id`);
80 #IfNotIndex pnotes pid
81 CREATE INDEX `pid` ON `pnotes` (`pid`);
84 #IfNotIndex transactions pid
85 CREATE INDEX `pid` ON `transactions` (`pid`);
88 #IfNotIndex extended_log patient_id
89 CREATE INDEX `patient_id` ON `extended_log` (`patient_id`);
92 #IfNotIndex prescriptions patient_id
93 CREATE INDEX `patient_id` ON `prescriptions` (`patient_id`);
96 #IfMissingColumn version v_realpatch
97 ALTER TABLE `version` ADD COLUMN `v_realpatch` int(11) NOT NULL DEFAULT 0;
100 #IfMissingColumn prescriptions drug_info_erx
101 ALTER TABLE `prescriptions` ADD COLUMN `drug_info_erx` TEXT DEFAULT NULL;
104 #IfNotRow2D list_options list_id lists option_id nation_notes_replace_buttons
105 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`) VALUES ('lists','nation_notes_replace_buttons','Nation Notes Replace Buttons',1);
106 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`) VALUES ('nation_notes_replace_buttons','Yes','Yes',10);
107 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`) VALUES ('nation_notes_replace_buttons','No','No',20);
108 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`) VALUES ('nation_notes_replace_buttons','Normal','Normal',30);
109 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`) VALUES ('nation_notes_replace_buttons','Abnormal','Abnormal',40);
112 #IfMissingColumn insurance_data policy_type
113 ALTER TABLE `insurance_data` ADD COLUMN `policy_type` varchar(25) NOT NULL default '';
116 #IfMissingColumn drugs max_level
117 ALTER TABLE drugs ADD max_level float NOT NULL DEFAULT 0.0;
118 ALTER TABLE drugs CHANGE reorder_point reorder_point float NOT NULL DEFAULT 0.0;
121 #IfNotTable product_warehouse
122 CREATE TABLE `product_warehouse` (
123 `pw_drug_id` int(11) NOT NULL,
124 `pw_warehouse` varchar(31) NOT NULL,
125 `pw_min_level` float DEFAULT 0,
126 `pw_max_level` float DEFAULT 0,
127 PRIMARY KEY (`pw_drug_id`,`pw_warehouse`)
131 # Increase size from 5 to 12 to support 4 modifiers with colon separation
132 #IfNotColumnType billing modifier varchar(12)
133 ALTER TABLE `billing` MODIFY `modifier` varchar(12);
134 UPDATE `code_types` SET `ct_mod` = '12' where ct_key = 'CPT4' OR ct_key = 'HCPCS';
137 #IfMissingColumn billing notecodes
138 ALTER TABLE `billing` ADD `notecodes` varchar(25) NOT NULL default '';
143 #IfNotTable dated_reminders
144 CREATE TABLE `dated_reminders` (
145 `dr_id` int(11) NOT NULL AUTO_INCREMENT,
146 `dr_from_ID` int(11) NOT NULL,
147 `dr_message_text` varchar(160) NOT NULL,
148 `dr_message_sent_date` datetime NOT NULL,
149 `dr_message_due_date` date NOT NULL,
150 `pid` int(11) NOT NULL,
151 `message_priority` tinyint(1) NOT NULL,
152 `message_processed` tinyint(1) NOT NULL DEFAULT '0',
153 `processed_date` timestamp NULL DEFAULT NULL,
154 `dr_processed_by` int(11) NOT NULL,
155 PRIMARY KEY (`dr_id`),
156 KEY `dr_from_ID` (`dr_from_ID`,`dr_message_due_date`)
157 ) ENGINE=MyISAM AUTO_INCREMENT=1;
160 #IfNotTable dated_reminders_link
161 CREATE TABLE `dated_reminders_link` (
162 `dr_link_id` int(11) NOT NULL AUTO_INCREMENT,
163 `dr_id` int(11) NOT NULL,
164 `to_id` int(11) NOT NULL,
165 PRIMARY KEY (`dr_link_id`),
166 KEY `to_id` (`to_id`),
167 KEY `dr_id` (`dr_id`)
168 ) ENGINE=MyISAM AUTO_INCREMENT=1;
171 #IfMissingColumn x12_partners x12_gs03
172 ALTER TABLE `x12_partners` ADD COLUMN `x12_gs03` VARCHAR(15) NOT NULL DEFAULT '';
175 #IfNotTable payment_gateway_details
176 CREATE TABLE `payment_gateway_details` (
177 `id` int(11) NOT NULL AUTO_INCREMENT,
178 `service_name` varchar(100) DEFAULT NULL,
179 `login_id` varchar(255) DEFAULT NULL,
180 `transaction_key` varchar(255) DEFAULT NULL,
181 `md5` varchar(255) DEFAULT NULL,
186 #IfNotRow2D list_options list_id lists option_id payment_gateways
187 insert into `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`) values('lists','payment_gateways','Payment Gateways','297','1','0','','');
188 insert into `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`) values('payment_gateways','authorize_net','Authorize.net','1','0','0','','');
191 #IfNotRow2D list_options list_id payment_method option_id authorize_net
192 insert into `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`) values('payment_method','authorize_net','Authorize.net','60','0','0','','');
195 #IfMissingColumn patient_access_offsite authorize_net_id
196 ALTER TABLE `patient_access_offsite` ADD COLUMN `authorize_net_id` VARCHAR(20) COMMENT 'authorize.net profile id';
199 #IfMissingColumn facility website
200 ALTER TABLE `facility` ADD COLUMN `website` varchar(255) default NULL;
203 #IfMissingColumn facility email
204 ALTER TABLE `facility` ADD COLUMN `email` varchar(255) default NULL;