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';