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 #IfNotRow clinical_rules id rule_blood_pressure
75 INSERT INTO `clinical_rules` ( `id`, `pid`, `active_alert_flag`, `passive_alert_flag`, `cqm_flag`, `cqm_nqf_code`, `cqm_pqri_code`, `amc_flag`, `amc_code`, `patient_reminder_flag` ) VALUES ('rule_blood_pressure', 0, 0, 0, 0, '', '', 0, '', 0);
78 #IfNotRow2D list_options list_id clinical_rules option_id rule_blood_pressure
79 INSERT INTO `list_options` ( `list_id`, `option_id`, `title`, `seq`, `is_default` ) VALUES ('clinical_rules', 'rule_blood_pressure', 'Measure Blood Pressure', 1610, 0);
82 #IfNotRow rule_action id rule_blood_pressure
83 INSERT INTO `rule_action` ( `id`, `group_id`, `category`, `item` ) VALUES ('rule_blood_pressure', 1, 'act_cat_measure', 'act_bp');
86 #IfNotRow rule_reminder id rule_blood_pressure
87 INSERT INTO `rule_reminder` ( `id`, `method`, `method_detail`, `value` ) VALUES ('rule_blood_pressure', 'clinical_reminder_pre', 'week', '2');
88 INSERT INTO `rule_reminder` ( `id`, `method`, `method_detail`, `value` ) VALUES ('rule_blood_pressure', 'clinical_reminder_post', 'month', '1');
89 INSERT INTO `rule_reminder` ( `id`, `method`, `method_detail`, `value` ) VALUES ('rule_blood_pressure', 'patient_reminder_pre', 'week', '2');
90 INSERT INTO `rule_reminder` ( `id`, `method`, `method_detail`, `value` ) VALUES ('rule_blood_pressure', 'patient_reminder_post', 'month', '1');
93 #IfNotRow rule_target id rule_blood_pressure
94 INSERT INTO `rule_target` ( `id`, `group_id`, `include_flag`, `required_flag`, `method`, `value`, `interval` ) VALUES ('rule_blood_pressure', 1, 1, 1, 'target_database', '::form_vitals::bps::::::ge::1', 0);
95 INSERT INTO `rule_target` ( `id`, `group_id`, `include_flag`, `required_flag`, `method`, `value`, `interval` ) VALUES ('rule_blood_pressure', 1, 1, 1, 'target_database', '::form_vitals::bpd::::::ge::1', 0);
98 #IfNotRow clinical_rules id rule_inr_measure
99 INSERT INTO `clinical_rules` ( `id`, `pid`, `active_alert_flag`, `passive_alert_flag`, `cqm_flag`, `cqm_nqf_code`, `cqm_pqri_code`, `amc_flag`, `amc_code`, `patient_reminder_flag` ) VALUES ('rule_inr_measure', 0, 0, 0, 0, '', '', 0, '', 0);
102 #IfNotRow2D list_options list_id clinical_rules option_id rule_inr_measure
103 INSERT INTO `list_options` ( `list_id`, `option_id`, `title`, `seq`, `is_default` ) VALUES ('clinical_rules', 'rule_inr_measure', 'Measure INR', 1620, 0);
106 #IfNotRow rule_action id rule_inr_measure
107 INSERT INTO `rule_action` ( `id`, `group_id`, `category`, `item` ) VALUES ('rule_inr_measure', 1, 'act_cat_measure', 'act_lab_inr');
110 #IfNotRow rule_reminder id rule_inr_measure
111 INSERT INTO `rule_reminder` ( `id`, `method`, `method_detail`, `value` ) VALUES ('rule_inr_measure', 'clinical_reminder_pre', 'week', '2');
112 INSERT INTO `rule_reminder` ( `id`, `method`, `method_detail`, `value` ) VALUES ('rule_inr_measure', 'clinical_reminder_post', 'month', '1');
113 INSERT INTO `rule_reminder` ( `id`, `method`, `method_detail`, `value` ) VALUES ('rule_inr_measure', 'patient_reminder_pre', 'week', '2');
114 INSERT INTO `rule_reminder` ( `id`, `method`, `method_detail`, `value` ) VALUES ('rule_inr_measure', 'patient_reminder_post', 'month', '1');
117 #IfNotRow rule_target id rule_inr_measure
118 INSERT INTO `rule_target` ( `id`, `group_id`, `include_flag`, `required_flag`, `method`, `value`, `interval` ) VALUES ('rule_inr_measure', 1, 1, 1, 'target_proc', 'INR::CPT4:85610::::::ge::1', 0);
121 #IfMissingColumn patient_data billing_note
122 SET @group_name = (SELECT group_name FROM layout_options WHERE field_id='lname' AND form_id='DEM');
123 SET @backup_group_name = (SELECT group_name FROM layout_options WHERE field_id='DOB' AND form_id='DEM');
124 SET @seq = (SELECT MAX(seq) FROM layout_options WHERE group_name = IFNULL(@group_name,@backup_group_name) AND form_id='DEM');
125 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`) VALUES ('DEM', 'billing_note', IFNULL(@group_name,@backup_group_name), 'Billing Note', @seq+1, 2, 1, 60, 0, '', 1, 3, '', '', 'Patient Level Billing Note (Collections)' ) ;
126 ALTER TABLE patient_data ADD COLUMN billing_note text NOT NULL default '';
127 UPDATE `patient_data` SET `billing_note` = `genericval2` WHERE `genericname2` = 'Billing';
128 UPDATE `patient_data` SET `genericval2` = '', `genericname2` = '' WHERE `genericname2` = 'Billing';
131 #IfMissingColumn lang_languages lang_is_rtl
132 ALTER TABLE `lang_languages` ADD COLUMN `lang_is_rtl` TINYINT DEFAULT 0;
133 UPDATE `lang_languages` SET `lang_is_rtl`=1 WHERE `lang_code` IN ('he','ar') OR `lang_description` IN('Hebrew','Arabic');
136 #IfMissingColumn procedure_report date_collected_tz
137 ALTER TABLE `procedure_report` ADD COLUMN `date_collected_tz` varchar(5) DEFAULT '' COMMENT '+-hhmm offset from UTC';
140 #IfMissingColumn procedure_report date_report_tz
141 ALTER TABLE `procedure_report` ADD COLUMN `date_report_tz` varchar(5) DEFAULT '' COMMENT '+-hhmm offset from UTC';
144 UPDATE `clinical_rules` SET `cqm_2014_flag` = 1 WHERE `id` = 'rule_influenza_ge_50_cqm' AND `pid` = 0;
145 UPDATE `clinical_rules` SET `cqm_2014_flag` = 1 WHERE `id` = 'rule_dm_a1c_cqm' AND `pid` = 0;
147 #IfMissingColumn lists subtype
148 ALTER TABLE `lists` ADD COLUMN `subtype` varchar(31) NOT NULL DEFAULT '';
151 #IfMissingColumn list_options subtype
152 ALTER TABLE `list_options` ADD COLUMN `subtype` varchar(31) NOT NULL DEFAULT '';
155 #IfNotRow2D list_options list_id lists option_id issue_subtypes
156 INSERT INTO list_options (list_id,option_id,title) VALUES ('lists','issue_subtypes','Issue Subtypes');
157 INSERT INTO list_options (list_id, option_id,title, seq) VALUES ('issue_subtypes', 'eye', 'Eye',10);
160 UPDATE `clinical_rules` SET `amc_2014_stage1_flag` = 1, `amc_2014_stage2_flag` = 1 WHERE `id` = 'med_reconc_amc' AND `pid` = 0;
161 UPDATE `clinical_rules` SET `amc_2014_stage1_flag` = 1, `amc_2014_stage2_flag` = 1 WHERE `id` = 'med_reconc_amc' AND `pid` = 0;