Support Multiple Modifiers for real
[openemr.git] / sql / patch.sql
blobae7f3e7332dbae42e63c60863061cfce2299b839
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 --  #IfMissingColumn
13 --    arguments: table_name colname
14 --    behavior:  if the colname in the table_name table does not exist,  the block will be executed
16 --  #IfNotColumnType
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
20 --  #IfNotRow
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.
24 --  #IfNotRow2D
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.
28 --  #IfNotRow3D
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.
32 --  #IfNotRow4D
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.
36 --  #IfNotRow2Dx2
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.
43 --  #IfNotIndex
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
48 --  #EndIf
49 --    all blocks are terminated with and #EndIf statement.
51 #IfNotIndex lists type
52 CREATE INDEX `type` ON `lists` (`type`);
53 #EndIf
55 #IfNotIndex lists pid
56 CREATE INDEX `pid` ON `lists` (`pid`);
57 #EndIf
59 #IfNotIndex form_vitals pid
60 CREATE INDEX `pid` ON `form_vitals` (`pid`);
61 #EndIf
63 #IfNotIndex forms pid
64 CREATE INDEX `pid` ON `forms` (`pid`);
65 #EndIf
67 #IfNotIndex form_encounter pid
68 CREATE INDEX `pid` ON `form_encounter` (`pid`);
69 #EndIf
71 #IfNotIndex immunizations patient_id
72 CREATE INDEX `patient_id` ON `immunizations` (`patient_id`);
73 #EndIf
75 #IfNotIndex procedure_order patient_id
76 CREATE INDEX `patient_id` ON `procedure_order` (`patient_id`);
77 #EndIf
79 #IfNotIndex pnotes pid
80 CREATE INDEX `pid` ON `pnotes` (`pid`);
81 #EndIf
83 #IfNotIndex transactions pid
84 CREATE INDEX `pid` ON `transactions` (`pid`);
85 #EndIf
87 #IfNotIndex extended_log patient_id
88 CREATE INDEX `patient_id` ON `extended_log` (`patient_id`);
89 #EndIf
91 #IfNotIndex prescriptions patient_id
92 CREATE INDEX `patient_id` ON `prescriptions` (`patient_id`);
93 #EndIf
95 #IfMissingColumn version v_realpatch
96 ALTER TABLE `version` ADD COLUMN `v_realpatch` int(11) NOT NULL DEFAULT 0;
97 #EndIf
99 #IfMissingColumn prescriptions drug_info_erx
100 ALTER TABLE `prescriptions` ADD COLUMN `drug_info_erx` TEXT DEFAULT NULL;
101 #EndIf
103 #IfMissingColumn insurance_data policy_type
104 ALTER TABLE `insurance_data` ADD COLUMN `policy_type` varchar(25) NOT NULL default '';
105 #EndIf
107 #IfNotColumnType billing modifier varchar(12)
108    ALTER TABLE `billing` MODIFY `modifier` varchar(12);
109    UPDATE `code_types` SET `ct_mod` = '12' where ct_key = 'CPT4' OR ct_key = 'HCPCS';
110 #Endif