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 table and column exist, the block will be executed
17 -- arguments: table_name colname
18 -- behavior: if the table exists but the column does not, the block will be executed
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
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.
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.
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.
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.
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.
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.
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.
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.
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
66 -- all blocks are terminated with a #EndIf statement.
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.
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.
86 -- behavior: can take a long time.
89 -- To ensure proper compatibility with MySQL/MariaDB and InnoDB, changing all *TEXT fields to
90 -- correctly use NULL as default.
95 -- The following 4 tables were using AUTO_INCREMENT field in the end of primary key, which needed to be
96 -- modified to support InnoDB,
101 #IfTableEngine ar_activity MyISAM
102 ALTER TABLE `ar_activity` MODIFY `sequence_no` int UNSIGNED NOT NULL COMMENT 'Sequence_no, incremented in code';
103 ALTER TABLE `ar_activity` ENGINE="InnoDB";
108 #IfTableEngine claims MyISAM
109 ALTER TABLE `claims` MODIFY `version` int(10) UNSIGNED NOT NULL COMMENT 'Version, incremented in code';
110 ALTER TABLE `claims` ENGINE="InnoDB";
113 -- 3. procedure_answers
115 #IfTableEngine procedure_answers MyISAM
116 ALTER TABLE `procedure_answers` MODIFY `answer_seq` int(11) NOT NULL COMMENT 'Supports multiple-choice questions. Answer_seq, incremented in code';
117 ALTER TABLE `procedure_answers` ENGINE="InnoDB";
120 -- 4. procedure_order_code
122 #IfTableEngine procedure_order_code MyISAM
123 -- Modify the table for InnoDB
124 -- remove NOT NULL DEFAULT "" declaration from TEXT field.
125 -- remove AUTO_INCREMENT field declaration
126 ALTER TABLE `procedure_order_code` MODIFY `procedure_order_seq` int(11) NOT NULL COMMENT 'Supports multiple tests per order. Procedure_order_seq incremented in code';
127 ALTER TABLE `procedure_order_code` ENGINE="InnoDB";
131 -- Other tables do not need special treatment before conversion to InnoDB.
132 -- Warning: running this query can take a long time.
133 #IfInnoDBMigrationNeeded
134 -- Modifies all remaining MyISAM tables to InnoDB
138 CREATE TABLE `valueset` (
139 `nqf_code` varchar(255) NOT NULL DEFAULT '',
140 `code` varchar(255) NOT NULL DEFAULT '',
141 `code_system` varchar(255) NOT NULL DEFAULT '',
142 `code_type` varchar(255) DEFAULT NULL,
143 `valueset` varchar(255) NOT NULL DEFAULT '',
144 `description` varchar(255) DEFAULT NULL,
145 `valueset_name` varchar(500) DEFAULT NULL,
146 PRIMARY KEY (`nqf_code`,`code`,`valueset`)
150 #IfMissingColumn openemr_postcalendar_categories pc_active
151 ALTER TABLE `openemr_postcalendar_categories` ADD `pc_active` tinyint(1) NOT NULL DEFAULT 1;
154 #IfMissingColumn openemr_postcalendar_categories pc_seq
155 ALTER TABLE `openemr_postcalendar_categories` ADD `pc_seq` int(11) NOT NULL DEFAULT '0';
156 UPDATE `openemr_postcalendar_categories` set pc_seq = pc_catid;
159 -- Mu2 New Encounter Categories
160 #IfNotRow openemr_postcalendar_categories pc_catname Health and Behavioral Assessment
161 SET @catid = (SELECT MAX(pc_catid) FROM openemr_postcalendar_categories);
162 INSERT INTO `openemr_postcalendar_categories` (`pc_catid`, `pc_catname`, `pc_catcolor`, `pc_catdesc`, `pc_recurrtype`, `pc_enddate`, `pc_recurrspec`, `pc_recurrfreq`, `pc_duration`, `pc_end_date_flag`, `pc_end_date_type`, `pc_end_date_freq`, `pc_end_all_day`, `pc_dailylimit`, `pc_cattype`, `pc_active`, `pc_seq`) VALUES (@catid+1, 'Health and Behavioral Assessment', '#C7C7C7', 'Health and Behavioral Assessment', 0, NULL, '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";}', 0, 900, 0, 0, 0, 0, 0,0,1,@catid+1);
163 INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_hea_and_beh', @catid+1);
166 #IfNotRow openemr_postcalendar_categories pc_catname Preventive Care Services
167 SET @catid = (SELECT MAX(pc_catid) FROM openemr_postcalendar_categories);
168 INSERT INTO `openemr_postcalendar_categories` (`pc_catid`, `pc_catname`, `pc_catcolor`, `pc_catdesc`, `pc_recurrtype`, `pc_enddate`, `pc_recurrspec`, `pc_recurrfreq`, `pc_duration`, `pc_end_date_flag`, `pc_end_date_type`, `pc_end_date_freq`, `pc_end_all_day`, `pc_dailylimit`, `pc_cattype`, `pc_active`, `pc_seq`) VALUES (@catid+1, 'Preventive Care Services', '#CCCCFF', 'Preventive Care Services', 0, NULL, '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";}', 0, 900, 0, 0, 0, 0, 0,0,1,@catid+1);
169 INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_ind_counsel', @catid+1);
170 INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_group_counsel', @catid+1);
171 INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_other_serv', @catid+1);
172 INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_ser_18_older', @catid+1);
173 INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_ser_40_older', @catid+1);
176 #IfNotRow2D list_options list_id order_type option_id enc_checkup_procedure
177 SET @max_seq = (select max(seq) from list_options where list_id = 'order_type');
178 INSERT INTO `list_options` (`list_id`,`option_id`,`title`,`seq`,`is_default`) values ('order_type','enc_checkup_procedure','Encounter Checkup Procedure',@max_seq+10,0);
181 -- updating nqf code for cqm measure blood pressure
182 UPDATE `clinical_rules` set `cqm_nqf_code` = '0018' where `id` = 'rule_htn_bp_measure_cqm';
186 #IfMissingColumn immunizations information_source
187 ALTER TABLE `immunizations` ADD COLUMN `information_source` VARCHAR(31) DEFAULT NULL;
190 #IfMissingColumn immunizations refusal_reason
191 ALTER TABLE `immunizations` ADD COLUMN `refusal_reason` VARCHAR(31) DEFAULT NULL;
194 #IfMissingColumn immunizations ordering_provider
195 ALTER TABLE `immunizations` ADD COLUMN `ordering_provider` INT(11) DEFAULT NULL;
198 #IfNotRow2D list_options list_id lists option_id immunization_registry_status
199 INSERT INTO list_options (list_id, option_id, title) VALUES ('lists','immunization_registry_status','Immunization Registry Status');
200 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_registry_status','active','Active','A', '10');
201 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_registry_status','inactive_lost_to_follow_up','Inactive - Lost to follow - up','L', '20');
202 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_registry_status','inactive_moved_gone_elsewhere','Inactive - Moved or gone elsewhere','M', '30');
203 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_registry_status','inactive_permanently_inactive','Inactive - Permanently inactive','P', '40');
204 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_registry_status','inactive_unspecified','Inactive - Unspecified','I', '50');
205 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_registry_status','unknown','Unknown','U', '60');
208 #IfNotRow2D list_options list_id lists option_id publicity_code
209 INSERT INTO list_options (list_id, option_id, title) VALUES ('lists','publicity_code','Publicity Code');
210 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','no_reminder_recall','No reminder/recall','SI', '10');
211 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','reminder_recall_any_method','Reminder/recall - any method','02', '20');
212 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','reminder_recall_no_calls','Reminder/recall - no calls','03', '30');
213 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','reminder_only_any_method','Reminder only - any method','04', '40');
214 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','reminder_only_no_calls','Reminder only - no calls','05', '50');
215 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','recall_only_any_method','Recall only - any method','06', '60');
216 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','recall_only_no_calls','Recall only - no calls','07', '70');
217 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','reminder_recall_to_provider','Reminder/recall - to provider','08', '80');
218 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','reminder_to_provider','Reminder to provider','09', '90');
219 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','reminder_to_provider_no_recall','Only reminder to provider, no recall','10', '100');
220 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','recall_to_provider','Recall to provider','11', '110');
221 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('publicity_code','recall_to_provider_no_reminder','Only recall to provider, no reminder','12', '120');
224 #IfNotRow2D list_options list_id lists option_id immunization_refusal_reason
225 INSERT INTO list_options (list_id, option_id, title) VALUES ('lists','immunization_refusal_reason','Immunization Refusal Reason');
226 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_refusal_reason','parental_decision','Parental decision','00', '10');
227 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_refusal_reason','religious_exemption','Religious exemption','01', '20');
228 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_refusal_reason','other','Other','02', '30');
229 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_refusal_reason','patient_decision','Patient decision','03', '40');
232 #IfNotRow2D list_options list_id lists option_id immunization_informationsource
233 INSERT INTO list_options (list_id, option_id, title) VALUES ('lists','immunization_informationsource','Immunization Information Source');
234 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_informationsource','new_immunization_record','New Immunization Record','00', '10');
235 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_informationsource','hist_inf_src_unspecified','Historical information -source unspecified','01', '20');
236 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_informationsource','other_provider','Other Provider','02', '30');
237 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_informationsource','parent_written_record','Parent Written Record','03', '40');
238 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_informationsource','parent_recall','Parent Recall','04', '50');
239 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_informationsource','other_registry','Other Registry','05', '60');
240 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_informationsource','birth_certificate','Birth Certificate','06', '70');
241 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_informationsource','school_record','School Record','07', '80');
242 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_informationsource','public_agency','Public Agency','08', '90');
245 #IfNotRow2D list_options list_id lists option_id next_of_kin_relationship
246 INSERT INTO `list_options` (list_id, option_id, title) VALUES ('lists','next_of_kin_relationship','Next of Kin Relationship');
247 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','associate','Associate','10','ASC');
248 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) values ('next_of_kin_relationship','brother','Brother','20','BRO');
249 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','care_giver','Care giver','30','CGV');
250 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','child','Child','40','CHD');
251 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','handicapped_dependent','Handicapped dependent','50','DEP');
252 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','life_partner','Life partner','60','DOM');
253 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','emergency_contact','Emergency contact','70','EMC');
254 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','employee','Employee','80','EME');
255 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','employer','Employer','90','EMR');
256 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','extended_family','Extended family','100','EXF');
257 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','foster_child','Foster Child','110','FCH');
258 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','friend','Friend','120','FND');
259 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','father','Father','130','FTH');
260 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','grandchild','Grandchild','140','GCH');
261 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','guardian','Guardian','150','GRD');
262 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','grandparent','Grandparent','160','GRP');
263 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','manager','Manager','170','MGR');
264 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','mother','Mother','180','MTH');
265 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','natural_child','Natural child','190','NCH');
266 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','none','None','200','NON');
267 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','other_adult','Other adult','210','OAD');
268 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','other','Other','220','OTH');
269 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','owner','Owner','230','OWN');
270 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','parent','Parent','240','PAR');
271 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','stepchild','Stepchild','250','SCH');
272 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','self','Self','260','SEL');
273 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','sibling','Sibling','270','SIB');
274 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','sister','Sister','280','SIS');
275 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','spouse','Spouse','290','SPO');
276 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','trainer','Trainer','300','TRA');
277 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','unknown','Unknown','310','UNK');
278 INSERT INTO `list_options` (list_id, option_id, title, seq, notes) VALUES ('next_of_kin_relationship','ward_of_court','Ward of court','320','WRD');
281 #IfNotRow2D list_options list_id lists option_id immunization_administered_site
282 INSERT INTO list_options (list_id, option_id, title) VALUES ('lists','immunization_administered_site','Immunization Administered Site');
283 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','left_thigh','Left Thigh','LT', '10');
284 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','left_arm','Left Arm','LA', '20');
285 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','left_deltoid','Left Deltoid','LD', '30');
286 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','left_gluteus_medius','Left Gluteus Medius','LG', '40');
287 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','left_vastus_lateralis','Left Vastus Lateralis','LVL', '50');
288 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','left_lower_forearm','Left Lower Forearm','LLFA', '60');
289 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','nose','Nose','Nose', '70');
290 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','right_arm','Right Arm','RA', '80');
291 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','right_thigh','Right Thigh','RT', '90');
292 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','right_vastus_lateralis','Right Vastus Lateralis','RVL', '100');
293 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','right_gluteus_medius','Right Gluteus Medius','RG', '110');
294 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','right_deltoid','Right Deltoid','RD', '120');
295 INSERT INTO list_options (list_id, option_id, title, notes, seq) VALUES ('immunization_administered_site','right_lower_forearm','Right Lower Forearm','RLFA', '130');
298 #IfNotRow2D list_options list_id lists option_id immunization_observation
299 INSERT INTO `list_options`(`list_id`, `option_id`, `title`) VALUES ('lists','immunization_observation','Immunization Observation Criteria');
300 INSERT INTO `list_options`(`list_id`, `option_id`, `title`, `seq`, `notes`, `codes`) VALUES ('immunization_observation','funding_program_eligibility','Vaccine funding program eligibility category','10','LN','LOINC:64994-7');
301 INSERT INTO `list_options`(`list_id`, `option_id`, `title`, `seq`, `notes`, `codes`) VALUES ('immunization_observation','vaccine_type','Vaccine Type','20','LN','LOINC:30956-7');
302 INSERT INTO `list_options`(`list_id`, `option_id`, `title`, `seq`, `notes`, `codes`) VALUES ('immunization_observation','disease_with_presumed_immunity','Disease with presumed immunity','30','LN','LOINC:59784-9');
305 #IfNotRow2D list_options list_id lists option_id imm_vac_eligibility_results
306 INSERT INTO `list_options`(`list_id`, `option_id`, `title`) VALUES ('lists','imm_vac_eligibility_results','Immunization Vaccine Eligibility Results');
307 INSERT INTO `list_options`(list_id, option_id, title, seq, notes) VALUES ('imm_vac_eligibility_results','not_vfc_eligible','Not VFC eligible','10','V01');
308 INSERT INTO `list_options`(list_id, option_id, title, seq, notes) VALUES ('imm_vac_eligibility_results','medicaid_managed_care','VFC eligible-Medicaid/Medicaid Managed Care','20','V02');
309 INSERT INTO `list_options`(list_id, option_id, title, seq, notes) VALUES ('imm_vac_eligibility_results','uninsured','VFC eligible- Uninsured','30','V03');
310 INSERT INTO `list_options`(list_id, option_id, title, seq, notes) VALUES ('imm_vac_eligibility_results','american_indian_alaskan_native','VFC eligible- American Indian/Alaskan Native','40','V04');
311 INSERT INTO `list_options`(list_id, option_id, title, seq, notes) VALUES ('imm_vac_eligibility_results','health_center_patient','VFC eligible-Federally Qualified Health Center Patient (under-insured)','50','V05');
314 #IfNotTable immunization_observation
315 CREATE TABLE `immunization_observation` (
316 `imo_id` int(11) NOT NULL AUTO_INCREMENT,
317 `imo_im_id` int(11) NOT NULL,
318 `imo_pid` int(11) DEFAULT NULL,
319 `imo_criteria` varchar(255) DEFAULT NULL,
320 `imo_criteria_value` varchar(255) DEFAULT NULL,
321 `imo_user` int(11) DEFAULT NULL,
322 `imo_code` varchar(255) DEFAULT NULL,
323 `imo_codetext` varchar(255) DEFAULT NULL,
324 `imo_codetype` varchar(255) DEFAULT NULL,
325 `imo_vis_date_published` date DEFAULT NULL,
326 `imo_vis_date_presented` date DEFAULT NULL,
327 `imo_date_observation` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
328 PRIMARY KEY (`imo_id`)
332 #IfMissingColumn patient_data imm_reg_status
333 SET @group_name = (SELECT group_name FROM layout_options WHERE form_id='DEM' AND group_name LIKE '%Choices' LIMIT 1);
334 SET @backup_group_name = (SELECT group_name FROM layout_options WHERE field_id='hipaa_notice' AND form_id='DEM');
335 SET @seq = (SELECT MAX(seq) FROM layout_options WHERE group_name = IFNULL(@group_name,@backup_group_name) AND form_id='DEM');
336 INSERT INTO `layout_options` (`form_id`, `field_id`, `group_name`, `title`, `seq`, `data_type`, `uor`, `fld_length`, `max_length`, `list_id`, `titlecols`, `datacols`, `default_value`, `edit_options`, `description`, `fld_rows`) VALUES ('DEM', 'imm_reg_status', IFNULL(@group_name,@backup_group_name), 'Immunization Registry Status', @seq+1, 1, 1, 1, 0, 'immunization_registry_status', 1, 1, '', '', 'Immunization Registry Status', 0) ;
337 ALTER TABLE `patient_data` ADD COLUMN `imm_reg_status` TEXT;
340 #IfMissingColumn patient_data imm_reg_stat_effdate
341 SET @group_name = (SELECT group_name FROM layout_options WHERE form_id='DEM' AND group_name LIKE '%Choices' LIMIT 1);
342 SET @backup_group_name = (SELECT group_name FROM layout_options WHERE field_id='hipaa_notice' AND form_id='DEM');
343 SET @seq = (SELECT MAX(seq) FROM layout_options WHERE group_name = IFNULL(@group_name,@backup_group_name) AND form_id='DEM');
344 INSERT INTO `layout_options` (`form_id`, `field_id`, `group_name`, `title`, `seq`, `data_type`, `uor`, `fld_length`, `max_length`, `list_id`, `titlecols`, `datacols`, `default_value`, `edit_options`, `description`, `fld_rows`) VALUES ('DEM', 'imm_reg_stat_effdate', IFNULL(@group_name,@backup_group_name), 'Immunization Registry Status Effective Date', @seq+1, 4, 1, 10, 10, '', 1, 1, '', '', 'Immunization Registry Status Effective Date', 0) ;
345 ALTER TABLE `patient_data` ADD COLUMN `imm_reg_stat_effdate` TEXT;
348 #IfMissingColumn patient_data publicity_code
349 SET @group_name = (SELECT group_name FROM layout_options WHERE form_id='DEM' AND group_name LIKE '%Choices' LIMIT 1);
350 SET @backup_group_name = (SELECT group_name FROM layout_options WHERE field_id='hipaa_notice' AND form_id='DEM');
351 SET @seq = (SELECT MAX(seq) FROM layout_options WHERE group_name = IFNULL(@group_name,@backup_group_name) AND form_id='DEM');
352 INSERT INTO `layout_options` (`form_id`, `field_id`, `group_name`, `title`, `seq`, `data_type`, `uor`, `fld_length`, `max_length`, `list_id`, `titlecols`, `datacols`, `default_value`, `edit_options`, `description`, `fld_rows`) VALUES ('DEM', 'publicity_code', IFNULL(@group_name,@backup_group_name), 'Publicity Code', @seq+1, 1, 1, 1, 0, 'publicity_code', 1, 1, '', '', 'Publicity Code', 0) ;
353 ALTER TABLE `patient_data` ADD COLUMN `publicity_code` TEXT;
356 #IfMissingColumn patient_data publ_code_eff_date
357 SET @group_name = (SELECT group_name FROM layout_options WHERE form_id='DEM' AND group_name LIKE '%Choices' LIMIT 1);
358 SET @backup_group_name = (SELECT group_name FROM layout_options WHERE field_id='hipaa_notice' AND form_id='DEM');
359 SET @seq = (SELECT MAX(seq) FROM layout_options WHERE group_name = IFNULL(@group_name,@backup_group_name) AND form_id='DEM');
360 INSERT INTO `layout_options` (`form_id`, `field_id`, `group_name`, `title`, `seq`, `data_type`, `uor`, `fld_length`, `max_length`, `list_id`, `titlecols`, `datacols`, `default_value`, `edit_options`, `description`, `fld_rows`) VALUES ('DEM', 'publ_code_eff_date', IFNULL(@group_name,@backup_group_name), 'Publicity Code Effective Date', @seq+1, 4, 1, 10, 10, '', 1, 1, '', '', 'Publicity Code Effective Date', 0) ;
361 ALTER TABLE `patient_data` ADD COLUMN `publ_code_eff_date` TEXT;
364 #IfMissingColumn patient_data protect_indicator
365 SET @group_name = (SELECT group_name FROM layout_options WHERE form_id='DEM' AND group_name LIKE '%Choices' LIMIT 1);
366 SET @backup_group_name = (SELECT group_name FROM layout_options WHERE field_id='hipaa_notice' AND form_id='DEM');
367 SET @seq = (SELECT MAX(seq) FROM layout_options WHERE group_name = IFNULL(@group_name,@backup_group_name) AND form_id='DEM');
368 INSERT INTO `layout_options` (`form_id`, `field_id`, `group_name`, `title`, `seq`, `data_type`, `uor`, `fld_length`, `max_length`, `list_id`, `titlecols`, `datacols`, `default_value`, `edit_options`, `description`, `fld_rows`) VALUES ('DEM', 'protect_indicator', IFNULL(@group_name,@backup_group_name), 'Protection Indicator', @seq+1, 1, 1, 1, 0, 'yesno', 1, 1, '', '', 'Protection Indicator', 0) ;
369 ALTER TABLE `patient_data` ADD COLUMN `protect_indicator` TEXT;
372 #IfMissingColumn patient_data prot_indi_effdate
373 SET @group_name = (SELECT group_name FROM layout_options WHERE form_id='DEM' AND group_name LIKE '%Choices' LIMIT 1);
374 SET @backup_group_name = (SELECT group_name FROM layout_options WHERE field_id='hipaa_notice' AND form_id='DEM');
375 SET @seq = (SELECT MAX(seq) FROM layout_options WHERE group_name = IFNULL(@group_name,@backup_group_name) AND form_id='DEM');
376 INSERT INTO `layout_options` (`form_id`, `field_id`, `group_name`, `title`, `seq`, `data_type`, `uor`, `fld_length`, `max_length`, `list_id`, `titlecols`, `datacols`, `default_value`, `edit_options`, `description`, `fld_rows`) VALUES ('DEM', 'prot_indi_effdate', IFNULL(@group_name,@backup_group_name), 'Protection Indicator Effective Date', @seq+1, 4, 1, 10, 10, '', 1, 1, '', '', 'Protection Indicator Effective Date', 0) ;
377 ALTER TABLE `patient_data` ADD COLUMN `prot_indi_effdate` TEXT;
380 #IfRow2D layout_options form_id DEM field_id guardiansname
381 UPDATE `layout_options` SET group_name='8Guardian',title='Name',seq='10' WHERE form_id='DEM' AND field_id='guardiansname' AND group_name LIKE '%Contact';
384 #IfNotColumnType patient_data guardiansname TEXT
385 ALTER TABLE `patient_data` MODIFY `guardiansname` TEXT;
388 #IfMissingColumn patient_data guardiansname
389 ALTER TABLE patient_data ADD COLUMN `guardiansname` TEXT;
392 #IfMissingColumn patient_data guardianrelationship
393 ALTER TABLE `patient_data` ADD COLUMN `guardianrelationship` TEXT;
394 INSERT INTO `layout_options` (`form_id`,`field_id`,`group_name`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('DEM', 'guardianrelationship' , '8Guardian', 'Relationship' ,20, 1, 1,0,0, 'next_of_kin_relationship', 1, 1, '', '', 'Relationship', 0);
397 #IfMissingColumn patient_data guardiansex
398 ALTER TABLE `patient_data` ADD COLUMN `guardiansex` TEXT;
399 INSERT INTO `layout_options` (`form_id`,`field_id`,`group_name`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('DEM', 'guardiansex' , '8Guardian', 'Sex' ,30, 1, 1,0,0, 'sex', 1, 1, '', '', 'Sex', 0);
402 #IfMissingColumn patient_data guardianaddress
403 ALTER TABLE `patient_data` ADD COLUMN `guardianaddress` TEXT;
404 INSERT INTO `layout_options` (`form_id`,`field_id`,`group_name`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('DEM', 'guardianaddress' , '8Guardian', 'Address' ,40, 2, 1,25,63, '', 1, 1, '', '', 'Address', 0);
407 #IfMissingColumn patient_data guardiancity
408 ALTER TABLE `patient_data` ADD COLUMN `guardiancity` TEXT;
409 INSERT INTO `layout_options` (`form_id`,`field_id`,`group_name`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('DEM', 'guardiancity' , '8Guardian', 'City' ,50, 2, 1,15,63, '', 1, 1, '', '', 'City', 0);
412 #IfMissingColumn patient_data guardianstate
413 ALTER TABLE `patient_data` ADD COLUMN `guardianstate` TEXT;
414 INSERT INTO `layout_options` (`form_id`,`field_id`,`group_name`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('DEM', 'guardianstate' , '8Guardian', 'State' ,60, 26, 1,0,0, 'state', 1, 1, '', '', 'State', 0);
417 #IfMissingColumn patient_data guardianpostalcode
418 ALTER TABLE `patient_data` ADD COLUMN `guardianpostalcode` TEXT;
419 INSERT INTO `layout_options` (`form_id`,`field_id`,`group_name`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('DEM', 'guardianpostalcode' , '8Guardian', 'Postal Code' ,70, 2, 1,6,63, '', 1, 1, '', '', 'Postal Code', 0);
422 #IfMissingColumn patient_data guardiancountry
423 ALTER TABLE `patient_data` ADD COLUMN `guardiancountry` TEXT;
424 INSERT INTO `layout_options` (`form_id`,`field_id`,`group_name`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('DEM', 'guardiancountry' , '8Guardian', 'Country' ,80, 26, 1,0,0, 'country', 1, 1, '', '', 'Country', 0);
427 #IfMissingColumn patient_data guardianphone
428 ALTER TABLE `patient_data` ADD COLUMN `guardianphone` TEXT;
429 INSERT INTO `layout_options` (`form_id`,`field_id`,`group_name`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('DEM', 'guardianphone' , '8Guardian', 'Phone' ,90, 2, 1,20,63, '', 1, 1, '', '', 'Phone', 0);
432 #IfMissingColumn patient_data guardianworkphone
433 ALTER TABLE `patient_data` ADD COLUMN `guardianworkphone` TEXT;
434 INSERT INTO `layout_options` (`form_id`,`field_id`,`group_name`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('DEM', 'guardianworkphone' , '8Guardian', 'Work Phone' ,100, 2, 1,20,63, '', 1, 1, '', '', 'Work Phone', 0);
437 #IfMissingColumn patient_data guardianemail
438 ALTER TABLE `patient_data` ADD COLUMN `guardianemail` TEXT;
439 INSERT INTO `layout_options` (`form_id`,`field_id`,`group_name`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('DEM', 'guardianemail' , '8Guardian', 'Email' ,110, 2, 1,20,63, '', 1, 1, '', '', 'Guardian Email Address', 0);
442 #IfNotRow2D list_options list_id drug_units title mL
443 SET @option_id = (SELECT MAX(CAST(option_id AS UNSIGNED)) FROM list_options WHERE list_id = 'drug_units');
444 SET @seq = (SELECT MAX(seq) FROM list_options WHERE list_id = 'drug_units');
445 INSERT INTO `list_options` ( `list_id`, `option_id`, `title`, `seq`, `is_default` ) VALUES ('drug_units', @option_id+1, 'mL', @seq+1, 0);
448 #IfNotRow2Dx2 list_options list_id drug_route option_id intramuscular title Intramuscular
449 INSERT INTO list_options ( `list_id`, `option_id`, `title`, `seq`, `is_default`, `notes`, `codes` ) VALUES ('drug_route','intramuscular','Intramuscular' ,20, 0, 'IM', 'NCI-CONCEPT-ID:C28161');
452 #IfNotRow3D list_options list_id yesno option_id NO notes N
453 UPDATE `list_options` SET notes='N' WHERE list_id='yesno' and option_id='NO';
456 #IfNotRow3D list_options list_id yesno option_id YES notes Y
457 UPDATE `list_options` SET notes='Y' WHERE list_id='yesno' and option_id='YES';
460 #IfNotRow2Dx2 list_options list_id reaction option_id shortness_of_breath title Shortness of Breath
461 INSERT INTO `list_options` ( `list_id`, `option_id`, `title`, `seq`, `codes` ) VALUES ('reaction', 'shortness_of_breath', 'Shortness of Breath', 40, 'SNOMED-CT:267036007');
464 #IfNotRow2Dx2 list_options list_id drug_route option_id inhale title Inhale
465 INSERT INTO `list_options` ( `list_id`, `option_id`, `title`, `seq`, `notes`, `codes` ) VALUES ('drug_route','inhale','Inhale' , 16, 'RESPIR', 'NCI-CONCEPT-ID:C38216');
468 #IfNotRow3D list_options list_id drug_route codes NCI-CONCEPT-ID:C38288 title Per Oris
469 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C38288' WHERE list_id='drug_route' and title='Per Oris';
472 #IfNotColumnType immunizations cvx_code varchar(10)
473 ALTER TABLE `immunizations` MODIFY `cvx_code` varchar(10) default NULL;
476 #IfMissingColumn drugs drug_code
477 ALTER TABLE drugs ADD COLUMN drug_code VARCHAR(25) NULL;
480 #IfNotRow code_types ct_key NCI-CONCEPT-ID
481 DROP TABLE IF EXISTS `temp_table_one`;
482 CREATE TABLE `temp_table_one` (`id` int(11) NOT NULL DEFAULT '0',`seq` int(11) NOT NULL DEFAULT '0') ENGINE=MyISAM;
483 INSERT INTO `temp_table_one` (`id`, `seq`) VALUES (
484 IF(((SELECT MAX(`ct_id` ) FROM `code_types`) >= 100), ((SELECT MAX(`ct_id` ) FROM `code_types`) + 1), 100),
485 IF(((SELECT MAX(`ct_seq`) FROM `code_types`) >= 100), ((SELECT MAX(`ct_seq`) FROM `code_types`) + 1), 100));
486 INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, ct_nofs, ct_diag, ct_active, ct_label, ct_external, ct_claim, ct_proc, ct_term, ct_problem ) VALUES ('NCI-CONCEPT-ID', (SELECT MAX(`id`) FROM `temp_table_one`), (SELECT MAX(`seq`) FROM `temp_table_one`), 0, '', 0, 0, 1, 0, 1, 'NCI CONCEPT ID', 0, 0, 0, 0, 0);
487 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('suspension','C60928',(SELECT MAX(`id` ) FROM `temp_table_one`));
488 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('tablet','C42998',(SELECT MAX(`id` ) FROM `temp_table_one`));
489 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('capsule','C25158',(SELECT MAX(`id` ) FROM `temp_table_one`));
490 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('solution','C42986',(SELECT MAX(`id` ) FROM `temp_table_one`));
491 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('tsp','C48544',(SELECT MAX(`id` ) FROM `temp_table_one`));
492 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('ml','C28254',(SELECT MAX(`id` ) FROM `temp_table_one`));
493 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('units','C44278',(SELECT MAX(`id` ) FROM `temp_table_one`));
494 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('inhalations','C42944',(SELECT MAX(`id` ) FROM `temp_table_one`));
495 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('gtts(drops)','C48491',(SELECT MAX(`id` ) FROM `temp_table_one`));
496 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('cream','C28944',(SELECT MAX(`id` ) FROM `temp_table_one`));
497 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('ointment','C42966',(SELECT MAX(`id` ) FROM `temp_table_one`));
498 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('Per Oris','C38288',(SELECT MAX(`id` ) FROM `temp_table_one`));
499 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('Inhale','C38216',(SELECT MAX(`id` ) FROM `temp_table_one`));
500 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('Intramuscular','C28161',(SELECT MAX(`id` ) FROM `temp_table_one`));
501 INSERT INTO `codes` (`code_text`,`code`,`code_type`) VALUES ('mg','C28253',(SELECT MAX(`id` ) FROM `temp_table_one`));
502 DROP TABLE `temp_table_one`;
505 #IfNotRow3D list_options list_id drug_units title mg codes NCI-CONCEPT-ID:C28253
506 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C28253' WHERE list_id='drug_units' and title='mg';
509 #IfNotRow3D list_options list_id drug_form title suspension codes NCI-CONCEPT-ID:C60928
510 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C60928' WHERE list_id='drug_form' and title='suspension';
513 #IfNotRow3D list_options list_id drug_form title tablet codes NCI-CONCEPT-ID:C42998
514 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C42998' WHERE list_id='drug_form' and title='tablet';
517 #IfNotRow3D list_options list_id drug_form title capsule codes NCI-CONCEPT-ID:C25158
518 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C25158' WHERE list_id='drug_form' and title='capsule';
521 #IfNotRow3D list_options list_id drug_form title solution codes NCI-CONCEPT-ID:C42986
522 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C42986' WHERE list_id='drug_form' and title='solution';
525 #IfNotRow3D list_options list_id drug_form title tsp codes NCI-CONCEPT-ID:C48544
526 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C48544' WHERE list_id='drug_form' and title='tsp';
529 #IfNotRow3D list_options list_id drug_form title ml codes NCI-CONCEPT-ID:C28254
530 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C28254' WHERE list_id='drug_form' and title='ml';
533 #IfNotRow3D list_options list_id drug_form title units codes NCI-CONCEPT-ID:C44278
534 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C44278' WHERE list_id='drug_form' and title='units';
537 #IfNotRow3D list_options list_id drug_form title inhalations codes NCI-CONCEPT-ID:C42944
538 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C42944' WHERE list_id='drug_form' and title='inhalations';
541 #IfNotRow3D list_options list_id drug_form title gtts(drops) codes NCI-CONCEPT-ID:C48491
542 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C48491' WHERE list_id='drug_form' and title='gtts(drops)';
545 #IfNotRow3D list_options list_id drug_form title cream codes NCI-CONCEPT-ID:C28944
546 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C28944' WHERE list_id='drug_form' and title='cream';
549 #IfNotRow3D list_options list_id drug_form title ointment codes NCI-CONCEPT-ID:C42966
550 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C42966' WHERE list_id='drug_form' and title='ointment';
553 #IfNotRow2D list_options list_id drug_form title puff
554 SET @option_id = (SELECT MAX(CAST(option_id AS UNSIGNED)) FROM list_options WHERE list_id = 'drug_form');
555 SET @seq = (SELECT MAX(seq) FROM list_options WHERE list_id = 'drug_form');
556 INSERT INTO `list_options` ( `list_id`, `option_id`, `title`, `seq`, `is_default`, `codes` ) VALUES ('drug_form', @option_id+1, 'puff', @seq+1, 0, 'NCI-CONCEPT-ID:C42944');
559 #IfNotRow3D list_options list_id drug_route title Inhale codes NCI-CONCEPT-ID:C38216
560 UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C38216' WHERE list_id='drug_route' and title='Inhale';
563 #IfNotRow openemr_postcalendar_categories pc_catname Ophthalmological Services
564 SET @catid = (SELECT MAX(pc_catid) FROM openemr_postcalendar_categories);
565 INSERT INTO `openemr_postcalendar_categories` VALUES (@catid+1, 'Ophthalmological Services', '#F89219', 'Ophthalmological Services', 0, NULL, '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";}', 0, 900, 0, 0, 0, 0, 0,0,1,@catid+1);
566 INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_ophthal_serv', @catid+1);
569 #IfRow2D enc_category_map rule_enc_id enc_hea_and_beh main_cat_id 5
570 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_hea_and_beh' and main_cat_id = 5;
573 #IfRow2D enc_category_map rule_enc_id enc_hea_and_beh main_cat_id 9
574 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_hea_and_beh' and main_cat_id = 9;
577 #IfRow2D enc_category_map rule_enc_id enc_hea_and_beh main_cat_id 10
578 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_hea_and_beh' and main_cat_id = 10;
581 #IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_18_older main_cat_id 5
582 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_18_older' and main_cat_id = 5;
585 #IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_18_older main_cat_id 9
586 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_18_older' and main_cat_id = 9;
589 #IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_18_older main_cat_id 10
590 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_18_older' and main_cat_id = 10;
593 #IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_40_older main_cat_id 5
594 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_40_older' and main_cat_id = 5;
597 #IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_40_older main_cat_id 9
598 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_40_older' and main_cat_id = 9;
601 #IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_40_older main_cat_id 10
602 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_40_older' and main_cat_id = 10;
605 #IfRow2D enc_category_map rule_enc_id enc_pre_ind_counsel main_cat_id 5
606 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_ind_counsel' and main_cat_id = 5;
609 #IfRow2D enc_category_map rule_enc_id enc_pre_ind_counsel main_cat_id 9
610 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_ind_counsel' and main_cat_id = 9;
613 #IfRow2D enc_category_map rule_enc_id enc_pre_ind_counsel main_cat_id 10
614 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_ind_counsel' and main_cat_id = 10;
617 #IfRow2D enc_category_map rule_enc_id enc_pre_med_group_counsel main_cat_id 5
618 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_group_counsel' and main_cat_id = 5;
621 #IfRow2D enc_category_map rule_enc_id enc_pre_med_group_counsel main_cat_id 9
622 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_group_counsel' and main_cat_id = 9;
625 #IfRow2D enc_category_map rule_enc_id enc_pre_med_group_counsel main_cat_id 10
626 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_group_counsel' and main_cat_id = 10;
630 #IfRow2D enc_category_map rule_enc_id enc_pre_med_other_serv main_cat_id 5
631 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_other_serv' and main_cat_id = 5;
634 #IfRow2D enc_category_map rule_enc_id enc_pre_med_other_serv main_cat_id 9
635 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_other_serv' and main_cat_id = 9;
638 #IfRow2D enc_category_map rule_enc_id enc_pre_med_other_serv main_cat_id 10
639 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_other_serv' and main_cat_id = 10;
642 #IfRow2D enc_category_map rule_enc_id enc_pregnancy main_cat_id 5
643 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pregnancy' and main_cat_id = 5;
646 #IfRow2D enc_category_map rule_enc_id enc_pregnancy main_cat_id 9
647 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pregnancy' and main_cat_id = 9;
650 #IfRow2D enc_category_map rule_enc_id enc_pregnancy main_cat_id 10
651 DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pregnancy' and main_cat_id = 10;