Security fixes.
[openemr.git] / sql / 2_8_3-to-2_9_0_upgrade.sql
blob98f729432b5cbc811e850b9a057c1df536ead968
1 #IfMissingColumn form_encounter billing_note
2 ALTER TABLE form_encounter
3   ADD billing_note text NOT NULL DEFAULT '';
4 #EndIf
6 #IfMissingColumn users organization
7 ALTER TABLE users
8   ADD organization varchar(255) NOT NULL DEFAULT '',
9   ADD valedictory  varchar(255) NOT NULL DEFAULT '';
10 #EndIf
12 #IfMissingColumn openemr_postcalendar_events pc_facility
13 ALTER TABLE openemr_postcalendar_events
14   ADD pc_facility smallint(6) NOT NULL default '0' COMMENT 'facility id for this event';
15 #EndIf
17 #IfMissingColumn payments encounter
18 ALTER TABLE payments
19   ADD encounter bigint(20) NOT NULL DEFAULT 0,
20   ADD KEY pid (pid);
21 #EndIf
23 #IfMissingColumn patient_data usertext1
24 ALTER TABLE patient_data
25   ADD `usertext1`  varchar(255) NOT NULL DEFAULT '',
26   ADD `usertext2`  varchar(255) NOT NULL DEFAULT '',
27   ADD `userlist1`  varchar(255) NOT NULL DEFAULT '',
28   ADD `userlist2`  varchar(255) NOT NULL DEFAULT '',
29   ADD `pricelevel` varchar(255) NOT NULL DEFAULT 'standard';
30 #EndIf
32 #IfNotTable list_options
33 CREATE TABLE list_options (
34   list_id        varchar(31)   NOT NULL,
35   option_id      varchar(31)   NOT NULL,
36   title          varchar(255)  NOT NULL DEFAULT '',
37   seq            int(11)       NOT NULL DEFAULT 0,
38   is_default     tinyint(1)    NOT NULL DEFAULT 0,
39   option_value   float         NOT NULL DEFAULT 0,
40   PRIMARY KEY (list_id, option_id)
41 ) ENGINE=MyISAM;
42 INSERT INTO list_options VALUES ('yesno'  ,'NO' ,'NO' ,1,0,0);
43 INSERT INTO list_options VALUES ('yesno'  ,'YES','YES',2,0,0);
44 INSERT INTO list_options VALUES ('titles' ,'Mr.'   ,'Mr.'    ,1,0,0);
45 INSERT INTO list_options VALUES ('titles' ,'Mrs.'  ,'Mrs.'   ,2,0,0);
46 INSERT INTO list_options VALUES ('titles' ,'Ms.'   ,'Ms.'    ,3,0,0);
47 INSERT INTO list_options VALUES ('titles' ,'Dr.'   ,'Dr.'    ,4,0,0);
48 INSERT INTO list_options VALUES ('sex'    ,'Female','Female' ,1,0,0);
49 INSERT INTO list_options VALUES ('sex'    ,'Male'  ,'Male'   ,2,0,0);
50 INSERT INTO list_options VALUES ('marital','married'         ,'Married'         ,1,0,0);
51 INSERT INTO list_options VALUES ('marital','single'          ,'Single'          ,2,0,0);
52 INSERT INTO list_options VALUES ('marital','divorced'        ,'Divorced'        ,3,0,0);
53 INSERT INTO list_options VALUES ('marital','widowed'         ,'Widowed'         ,4,0,0);
54 INSERT INTO list_options VALUES ('marital','separated'       ,'Separated'       ,5,0,0);
55 INSERT INTO list_options VALUES ('marital','domestic partner','Domestic Partner',6,0,0);
56 INSERT INTO list_options VALUES ('language','English','English',1,0,0);
57 INSERT INTO list_options VALUES ('language','Spanish','Spanish',2,0,0);
58 INSERT INTO list_options VALUES ('ethrace','Caucasian','Caucasian',1,0,0);
59 INSERT INTO list_options VALUES ('ethrace','Asian'    ,'Asian'    ,2,0,0);
60 INSERT INTO list_options VALUES ('ethrace','Black'    ,'Black'    ,3,0,0);
61 INSERT INTO list_options VALUES ('ethrace','Hispanic' ,'Hispanic' ,4,0,0);
62 INSERT INTO list_options VALUES ('userlist1','sample','Sample',1,0,0);
63 INSERT INTO list_options VALUES ('userlist2','sample','Sample',1,0,0);
64 INSERT INTO list_options VALUES ('pricelevel','standard','Standard',1,1,0);
65 #EndIf
67 #IfNotTable layout_options
68 CREATE TABLE layout_options (
69   form_id        varchar(31)   NOT NULL,
70   field_id       varchar(31)   NOT NULL,
71   group_name     varchar(31)   NOT NULL DEFAULT '',
72   title          varchar(63)   NOT NULL DEFAULT '',
73   seq            int(11)       NOT NULL DEFAULT 0,
74   data_type      tinyint(3)    NOT NULL DEFAULT 0,
75   uor            tinyint(1)    NOT NULL DEFAULT 1,
76   fld_length     int(11)       NOT NULL DEFAULT 15,
77   max_length     int(11)       NOT NULL DEFAULT 0,
78   list_id        varchar(31)   NOT NULL DEFAULT '',
79   titlecols      tinyint(3)    NOT NULL DEFAULT 1,
80   datacols       tinyint(3)    NOT NULL DEFAULT 1,
81   default_value  varchar(255)  NOT NULL DEFAULT '',
82   edit_options   varchar(36)   NOT NULL DEFAULT '',
83   description    varchar(255)  NOT NULL DEFAULT '',
84   PRIMARY KEY (form_id, field_id, seq)
85 ) ENGINE=MyISAM;
86 INSERT INTO layout_options VALUES ('DEM','title'          ,'1Who','Name'          , 1, 1,1, 0, 0,'titles' ,1,1,'','' ,'Title');
87 INSERT INTO layout_options VALUES ('DEM','fname'          ,'1Who',''              , 2, 2,2,10,63,''       ,0,0,'','C','First Name');
88 INSERT INTO layout_options VALUES ('DEM','mname'          ,'1Who',''              , 3, 2,1, 2,63,''       ,0,0,'','C','Middle Name');
89 INSERT INTO layout_options VALUES ('DEM','lname'          ,'1Who',''              , 4, 2,2,10,63,''       ,0,0,'','C','Last Name');
90 INSERT INTO layout_options VALUES ('DEM','pubpid'         ,'1Who','External ID'   , 5, 2,1,10,15,''       ,1,1,'','' ,'External identifier');
91 INSERT INTO layout_options VALUES ('DEM','DOB'            ,'1Who','DOB'           , 6, 4,2,10,10,''       ,1,1,'','D','Date of Birth');
92 INSERT INTO layout_options VALUES ('DEM','sex'            ,'1Who','Sex'           , 7, 1,2, 0, 0,'sex'    ,1,1,'','' ,'Sex');
93 INSERT INTO layout_options VALUES ('DEM','ss'             ,'1Who','S.S.'          , 8, 2,1,11,11,''       ,1,1,'','' ,'Social Security Number');
94 INSERT INTO layout_options VALUES ('DEM','drivers_license','1Who','License/ID'    , 9, 2,1,15,63,''       ,1,1,'','' ,'Drivers License or State ID');
95 INSERT INTO layout_options VALUES ('DEM','status'         ,'1Who','Marital Status',10, 1,1, 0, 0,'marital',1,3,'','' ,'Marital Status');
96 INSERT INTO layout_options VALUES ('DEM','genericname1'   ,'1Who','User Defined'  ,11, 2,1,15,63,''       ,1,3,'','' ,'User Defined Field');
97 INSERT INTO layout_options VALUES ('DEM','genericval1'    ,'1Who',''              ,12, 2,1,15,63,''       ,0,0,'','' ,'User Defined Field');
98 INSERT INTO layout_options VALUES ('DEM','genericname2'   ,'1Who',''              ,13, 2,1,15,63,''       ,0,0,'','' ,'User Defined Field');
99 INSERT INTO layout_options VALUES ('DEM','genericval2'    ,'1Who',''              ,14, 2,1,15,63,''       ,0,0,'','' ,'User Defined Field');
100 INSERT INTO layout_options VALUES ('DEM','squad'          ,'1Who','Squad'         ,15,13,0, 0, 0,''       ,1,3,'','' ,'Squad Membership');
101 INSERT INTO layout_options VALUES ('DEM','pricelevel'     ,'1Who','Price Level'   ,16, 1,0, 0, 0,'pricelevel',1,1,'','' ,'Discount Level');
102 INSERT INTO layout_options VALUES ('DEM','street'              ,'2Contact','Address'          , 1, 2,1,25,63,''     ,1,1,'','C','Street and Number');
103 INSERT INTO layout_options VALUES ('DEM','city'                ,'2Contact','City'             , 2, 2,1,15,63,''     ,1,1,'','C','City Name');
104 INSERT INTO layout_options VALUES ('DEM','state'               ,'2Contact','State'            , 3, 2,1,15,63,''     ,1,1,'','C','State/Locality');
105 INSERT INTO layout_options VALUES ('DEM','postal_code'         ,'2Contact','Postal Code'      , 4, 2,1, 6,63,''     ,1,1,'','' ,'Postal Code');
106 INSERT INTO layout_options VALUES ('DEM','country_code'        ,'2Contact','Country'          , 5, 1,1, 0, 0,'country',1,1,'','','Country');
107 INSERT INTO layout_options VALUES ('DEM','contact_relationship','2Contact','Emergency Contact', 6, 2,1,10,63,''     ,1,1,'','C','Emergency Contact Person');
108 INSERT INTO layout_options VALUES ('DEM','phone_contact'       ,'2Contact','Emergency Phone'  , 7, 2,1,20,63,''     ,1,1,'','P','Emergency Contact Phone Number');
109 INSERT INTO layout_options VALUES ('DEM','phone_home'          ,'2Contact','Home Phone'       , 8, 2,1,20,63,''     ,1,1,'','P','Home Phone Number');
110 INSERT INTO layout_options VALUES ('DEM','phone_biz'           ,'2Contact','Work Phone'       , 9, 2,1,20,63,''     ,1,1,'','P','Work Phone Number');
111 INSERT INTO layout_options VALUES ('DEM','phone_cell'          ,'2Contact','Mobile Phone'     ,10, 2,1,20,63,''     ,1,1,'','P','Cell Phone Number');
112 INSERT INTO layout_options VALUES ('DEM','email'               ,'2Contact','Contact Email'    ,11, 2,1,30,95,''     ,1,1,'','' ,'Contact Email Address');
113 INSERT INTO layout_options VALUES ('DEM','providerID'   ,'3Choices','Provider'             , 1,11,2, 0, 0,''       ,1,3,'','' ,'Referring Provider');
114 INSERT INTO layout_options VALUES ('DEM','pharmacy_id'  ,'3Choices','Pharmacy'             , 2,12,1, 0, 0,''       ,1,3,'','' ,'Preferred Pharmacy');
115 INSERT INTO layout_options VALUES ('DEM','hipaa_notice' ,'3Choices','HIPAA Notice Received', 3, 1,1, 0, 0,'yesno'  ,1,1,'','' ,'Did you receive a copy of the HIPAA Notice?');
116 INSERT INTO layout_options VALUES ('DEM','hipaa_voice'  ,'3Choices','Allow Voice Message'  , 4, 1,1, 0, 0,'yesno'  ,1,1,'','' ,'Allow telephone messages?');
117 INSERT INTO layout_options VALUES ('DEM','hipaa_mail'   ,'3Choices','Allow Mail Message'   , 5, 1,1, 0, 0,'yesno'  ,1,1,'','' ,'Allow email messages?');
118 INSERT INTO layout_options VALUES ('DEM','hipaa_message','3Choices','Leave Message With'   , 6, 2,1,20,63,''       ,1,1,'','' ,'With whom may we leave a message?');
119 INSERT INTO layout_options VALUES ('DEM','occupation'    ,'4Employer','Occupation'      , 1, 2,1,20,63,''     ,1,1,'','C','Occupation');
120 INSERT INTO layout_options VALUES ('DEM','em_name'       ,'4Employer','Employer Name'   , 2, 2,1,20,63,''     ,1,1,'','C','Employer Name');
121 INSERT INTO layout_options VALUES ('DEM','em_street'     ,'4Employer','Employer Address', 3, 2,1,25,63,''     ,1,1,'','C','Street and Number');
122 INSERT INTO layout_options VALUES ('DEM','em_city'       ,'4Employer','City'            , 4, 2,1,15,63,''     ,1,1,'','C','City Name');
123 INSERT INTO layout_options VALUES ('DEM','em_state'      ,'4Employer','State'           , 5, 2,1,15,63,''     ,1,1,'','C','State/Locality');
124 INSERT INTO layout_options VALUES ('DEM','em_postal_code','4Employer','Postal Code'     , 6, 2,1, 6,63,''     ,1,1,'','' ,'Postal Code');
125 INSERT INTO layout_options VALUES ('DEM','em_country'    ,'4Employer','Country'         , 7, 2,1,10,63,''     ,1,1,'','C','Country');
126 INSERT INTO layout_options VALUES ('DEM','language'        ,'5Stats','Language'             , 1, 1,1, 0, 0,'language',1,1,'','' ,'Preferred Language');
127 INSERT INTO layout_options VALUES ('DEM','ethnoracial'     ,'5Stats','Race/Ethnicity'       , 2, 1,1, 0, 0,'ethrace' ,1,1,'','' ,'Ethnicity or Race');
128 INSERT INTO layout_options VALUES ('DEM','financial_review','5Stats','Financial Review Date', 3, 2,1,10,10,''        ,1,1,'','D','Financial Review Date');
129 INSERT INTO layout_options VALUES ('DEM','family_size'     ,'5Stats','Family Size'          , 4, 2,1,20,63,''        ,1,1,'','' ,'Family Size');
130 INSERT INTO layout_options VALUES ('DEM','monthly_income'  ,'5Stats','Monthly Income'       , 5, 2,1,20,63,''        ,1,1,'','' ,'Monthly Income');
131 INSERT INTO layout_options VALUES ('DEM','homeless'        ,'5Stats','Homeless, etc.'       , 6, 2,1,20,63,''        ,1,1,'','' ,'Homeless or similar?');
132 INSERT INTO layout_options VALUES ('DEM','interpretter'    ,'5Stats','Interpreter'          , 7, 2,1,20,63,''        ,1,1,'','' ,'Interpreter needed?');
133 INSERT INTO layout_options VALUES ('DEM','migrantseasonal' ,'5Stats','Migrant/Seasonal'     , 8, 2,1,20,63,''        ,1,1,'','' ,'Migrant or seasonal worker?');
134 INSERT INTO layout_options VALUES ('DEM','usertext1'       ,'6Misc','User Defined Text 1'   , 1, 2,0,10,63,''         ,1,1,'','' ,'User Defined');
135 INSERT INTO layout_options VALUES ('DEM','usertext2'       ,'6Misc','User Defined Text 2'   , 2, 2,0,10,63,''         ,1,1,'','' ,'User Defined');
136 INSERT INTO layout_options VALUES ('DEM','userlist1'       ,'6Misc','User Defined List 1'   , 9, 1,0, 0, 0,'userlist1',1,1,'','' ,'User Defined');
137 INSERT INTO layout_options VALUES ('DEM','userlist2'       ,'6Misc','User Defined List 2'   ,10, 1,0, 0, 0,'userlist2',1,1,'','' ,'User Defined');
138 #EndIf
140 #IfMissingColumn transactions refer_date
141 ALTER TABLE transactions
142   ADD `refer_date`              date         DEFAULT NULL,
143   ADD `refer_from`              int(11)      NOT NULL DEFAULT 0,
144   ADD `refer_to`                int(11)      NOT NULL DEFAULT 0,
145   ADD `refer_diag`              varchar(255) NOT NULL DEFAULT '',
146   ADD `refer_risk_level`        varchar(255) NOT NULL DEFAULT '',
147   ADD `refer_vitals`            tinyint(1)   NOT NULL DEFAULT 0,
148   ADD `reply_date`              date         DEFAULT NULL,
149   ADD `reply_from`              varchar(255) NOT NULL DEFAULT '',
150   ADD `reply_init_diag`         varchar(255) NOT NULL DEFAULT '',
151   ADD `reply_final_diag`        varchar(255) NOT NULL DEFAULT '',
152   ADD `reply_documents`         varchar(255) NOT NULL DEFAULT '',
153   ADD `reply_findings`          text         NOT NULL DEFAULT '',
154   ADD `reply_services`          text         NOT NULL DEFAULT '',
155   ADD `reply_recommend`         text         NOT NULL DEFAULT '',
156   ADD `reply_rx_refer`          text         NOT NULL DEFAULT '';
157 INSERT INTO layout_options VALUES ('REF','refer_date'      ,'1Referral','Referral Date'                  , 1, 4,2, 0,  0,''         ,1,1,'C','D','Date of referral');
158 INSERT INTO layout_options VALUES ('REF','refer_from'      ,'1Referral','Refer By'                       , 2,10,2, 0,  0,''         ,1,1,'' ,'' ,'Referral By');
159 INSERT INTO layout_options VALUES ('REF','refer_to'        ,'1Referral','Refer To'                       , 3,14,2, 0,  0,''         ,1,1,'' ,'' ,'Referral To');
160 INSERT INTO layout_options VALUES ('REF','body'            ,'1Referral','Reason'                         , 4, 3,2,30,  3,''         ,1,1,'' ,'' ,'Reason for referral');
161 INSERT INTO layout_options VALUES ('REF','refer_external'  ,'1Referral','External Referral'              , 5, 1,1, 0,  0,'boolean'  ,1,1,'' ,'' ,'External referral?');
162 INSERT INTO layout_options VALUES ('REF','refer_diag'      ,'1Referral','Referrer Diagnosis'             , 6, 2,1,30,255,''         ,1,1,'' ,'X','Referrer diagnosis');
163 INSERT INTO layout_options VALUES ('REF','refer_risk_level','1Referral','Risk Level'                     , 7, 1,1, 0,  0,'risklevel',1,1,'' ,'' ,'Level of urgency');
164 INSERT INTO layout_options VALUES ('REF','refer_vitals'    ,'1Referral','Include Vitals'                 , 8, 1,1, 0,  0,'boolean'  ,1,1,'' ,'' ,'Include vitals data?');
165 INSERT INTO layout_options VALUES ('REF','reply_date'      ,'2Counter-Referral','Reply Date'             , 9, 4,1, 0,  0,''         ,1,1,'' ,'D','Date of reply');
166 INSERT INTO layout_options VALUES ('REF','reply_from'      ,'2Counter-Referral','Reply From'             ,10, 2,1,30,255,''         ,1,1,'' ,'' ,'Who replied?');
167 INSERT INTO layout_options VALUES ('REF','reply_init_diag' ,'2Counter-Referral','Presumed Diagnosis'     ,11, 2,1,30,255,''         ,1,1,'' ,'' ,'Presumed diagnosis by specialist');
168 INSERT INTO layout_options VALUES ('REF','reply_final_diag','2Counter-Referral','Final Diagnosis'        ,12, 2,1,30,255,''         ,1,1,'' ,'' ,'Final diagnosis by specialist');
169 INSERT INTO layout_options VALUES ('REF','reply_documents' ,'2Counter-Referral','Documents'              ,13, 2,1,30,255,''         ,1,1,'' ,'' ,'Where may related scanned or paper documents be found?');
170 INSERT INTO layout_options VALUES ('REF','reply_findings'  ,'2Counter-Referral','Findings'               ,14, 3,1,30,  3,''         ,1,1,'' ,'' ,'Findings by specialist');
171 INSERT INTO layout_options VALUES ('REF','reply_services'  ,'2Counter-Referral','Services Provided'      ,15, 3,1,30,  3,''         ,1,1,'' ,'' ,'Service provided by specialist');
172 INSERT INTO layout_options VALUES ('REF','reply_recommend' ,'2Counter-Referral','Recommendations'        ,16, 3,1,30,  3,''         ,1,1,'' ,'' ,'Recommendations by specialist');
173 INSERT INTO layout_options VALUES ('REF','reply_rx_refer'  ,'2Counter-Referral','Prescriptions/Referrals',17, 3,1,30,  3,''         ,1,1,'' ,'' ,'Prescriptions and/or referrals by specialist');
174 INSERT INTO list_options VALUES ('risklevel','low'   ,'Low'   ,1,0,0);
175 INSERT INTO list_options VALUES ('risklevel','medium','Medium',2,1,0);
176 INSERT INTO list_options VALUES ('risklevel','high'  ,'High'  ,3,0,0);
177 INSERT INTO list_options VALUES ('boolean','0','No' ,1,0,0);
178 INSERT INTO list_options VALUES ('boolean','1','Yes',2,0,0);
179 #EndIf
181 #IfMissingColumn codes related_code
182 ALTER TABLE codes
183   ADD related_code varchar(255)  NOT NULL DEFAULT '' COMMENT 'may reference a related codes.code';
184 #EndIf
186 #IfNotTable prices
187 CREATE TABLE prices (
188   pr_id          varchar(11)   NOT NULL            COMMENT 'references codes.id or drugs.id',
189   pr_selector    varchar(15)   NOT NULL DEFAULT '' COMMENT 'template selector for drugs, empty for codes',
190   pr_level       varchar(31)   NOT NULL DEFAULT '' COMMENT 'price level',
191   pr_price       decimal(12,2) NOT NULL DEFAULT 0  COMMENT 'price in local currency',
192   PRIMARY KEY (pr_id, pr_selector, pr_level)
193 ) ENGINE=MyISAM;
194 INSERT INTO prices ( pr_id, pr_level, pr_price )
195   SELECT codes.id, 'standard', codes.fee FROM codes
196   WHERE codes.fee IS NOT NULL AND codes.fee > 0;
197 #EndIf
199 #IfMissingColumn codes taxrates
200 ALTER TABLE codes
201   ADD taxrates varchar(255) NOT NULL DEFAULT '' COMMENT 'tax rate names delimited by colons';
202 #EndIf
204 #IfMissingColumn drug_templates taxrates
205 ALTER TABLE drug_templates
206   ADD taxrates varchar(255) NOT NULL DEFAULT '' COMMENT 'tax rate names delimited by colons';
207 #EndIf
209 #IfMissingColumn drug_sales billed
210 ALTER TABLE drug_sales
211   ADD billed tinyint(1) NOT NULL DEFAULT 0 COMMENT 'indicates if the sale is posted to accounting';
212 UPDATE drug_sales
213   SET billed = 1 WHERE encounter > 0;
214 #EndIf
216 #IfMissingColumn form_encounter pc_catid
217 ALTER TABLE form_encounter
218   ADD pc_catid int(11) NOT NULL DEFAULT 5 COMMENT 'event category from openemr_postcalendar_categories';
219 #EndIf
221 #IfNotTable fee_sheet_options
222 CREATE TABLE fee_sheet_options (
223   fs_category varchar(63)  NOT NULL DEFAULT '' COMMENT 'Descriptive category name',
224   fs_option   varchar(63)  NOT NULL DEFAULT '' COMMENT 'Descriptive option name',
225   fs_codes    varchar(255) NOT NULL DEFAULT '' COMMENT 'multiple instances of type:id:selector;'
226 ) ENGINE=MyISAM;
227 INSERT INTO fee_sheet_options VALUES ('1New Patient','1Brief'  ,'CPT4|99201|');
228 INSERT INTO fee_sheet_options VALUES ('1New Patient','2Limited','CPT4|99202|');
229 INSERT INTO fee_sheet_options VALUES ('1New Patient','3Detailed','CPT4|99203|');
230 INSERT INTO fee_sheet_options VALUES ('1New Patient','4Extended','CPT4|99204|');
231 INSERT INTO fee_sheet_options VALUES ('1New Patient','5Comprehensive','CPT4|99205|');
232 INSERT INTO fee_sheet_options VALUES ('2Established Patient','1Brief'  ,'CPT4|99211|');
233 INSERT INTO fee_sheet_options VALUES ('2Established Patient','2Limited','CPT4|99212|');
234 INSERT INTO fee_sheet_options VALUES ('2Established Patient','3Detailed','CPT4|99213|');
235 INSERT INTO fee_sheet_options VALUES ('2Established Patient','4Extended','CPT4|99214|');
236 INSERT INTO fee_sheet_options VALUES ('2Established Patient','5Comprehensive','CPT4|99215|');
237 #EndIf
239 #IfMissingColumn users cal_ui
240 ALTER TABLE `users`
241   ADD COLUMN `cal_ui` tinyint(4) NOT NULL DEFAULT 1 COMMENT 'Specifies calendar display style';
242 #EndIf
244 #IfMissingColumn drugs related_code
245 ALTER TABLE drugs
246   ADD related_code varchar(255)  NOT NULL DEFAULT '' COMMENT 'may reference a related codes.code';
247 #EndIf
249 #IfNotColumnType billing justify varchar(255)
250 ALTER TABLE billing
251   MODIFY `justify` varchar(255) NOT NULL DEFAULT '';
252 #EndIf
254 #IfNotColumnType prescriptions quantity varchar(31)
255 ALTER TABLE prescriptions
256   MODIFY `quantity` varchar(31) default '';
257 #EndIf
259 #IfNotColumnType codes superbill varchar(31)
260 ALTER TABLE codes
261   MODIFY `superbill` varchar(31) default '';
262 INSERT INTO list_options VALUES ('superbill','newpt','New Patient'        ,1,0,0);
263 INSERT INTO list_options VALUES ('superbill','estpt','Established Patient',2,0,0);
264 #EndIf
266 #IfMissingColumn patient_data userlist3
267 ALTER TABLE patient_data
268   ADD `userlist3`  varchar(255) NOT NULL DEFAULT '',
269   ADD `userlist4`  varchar(255) NOT NULL DEFAULT '',
270   ADD `userlist5`  varchar(255) NOT NULL DEFAULT '',
271   ADD `userlist6`  varchar(255) NOT NULL DEFAULT '',
272   ADD `userlist7`  varchar(255) NOT NULL DEFAULT '',
273   ADD `regdate`    date DEFAULT NULL COMMENT 'Registration Date';
274 INSERT INTO list_options VALUES ('userlist3','sample','Sample',1,0,0);
275 INSERT INTO list_options VALUES ('userlist4','sample','Sample',1,0,0);
276 INSERT INTO list_options VALUES ('userlist5','sample','Sample',1,0,0);
277 INSERT INTO list_options VALUES ('userlist6','sample','Sample',1,0,0);
278 INSERT INTO list_options VALUES ('userlist7','sample','Sample',1,0,0);
279 INSERT INTO layout_options VALUES ('DEM','userlist3'       ,'6Misc','User Defined List 3'   ,11, 1,0, 0, 0,'userlist3',1,1,'','' ,'User Defined');
280 INSERT INTO layout_options VALUES ('DEM','userlist4'       ,'6Misc','User Defined List 4'   ,12, 1,0, 0, 0,'userlist4',1,1,'','' ,'User Defined');
281 INSERT INTO layout_options VALUES ('DEM','userlist5'       ,'6Misc','User Defined List 5'   ,13, 1,0, 0, 0,'userlist5',1,1,'','' ,'User Defined');
282 INSERT INTO layout_options VALUES ('DEM','userlist6'       ,'6Misc','User Defined List 6'   ,14, 1,0, 0, 0,'userlist6',1,1,'','' ,'User Defined');
283 INSERT INTO layout_options VALUES ('DEM','userlist7'       ,'6Misc','User Defined List 7'   ,15, 1,0, 0, 0,'userlist7',1,1,'','' ,'User Defined');
284 INSERT INTO layout_options VALUES ('DEM','regdate'         ,'6Misc','Registration Date'     ,16, 4,0,10,10,''         ,1,1,'','D','Start Date at This Clinic');
285 #EndIf
287 #IfNotRow list_options list_id refsource
288 INSERT INTO list_options VALUES ('refsource','Patient'      ,'Patient'      , 1,0,0);
289 INSERT INTO list_options VALUES ('refsource','Employee'     ,'Employee'     , 2,0,0);
290 INSERT INTO list_options VALUES ('refsource','Walk-In'      ,'Walk-In'      , 3,0,0);
291 INSERT INTO list_options VALUES ('refsource','Newspaper'    ,'Newspaper'    , 4,0,0);
292 INSERT INTO list_options VALUES ('refsource','Radio'        ,'Radio'        , 5,0,0);
293 INSERT INTO list_options VALUES ('refsource','T.V.'         ,'T.V.'         , 6,0,0);
294 INSERT INTO list_options VALUES ('refsource','Direct Mail'  ,'Direct Mail'  , 7,0,0);
295 INSERT INTO list_options VALUES ('refsource','Coupon'       ,'Coupon'       , 8,0,0);
296 INSERT INTO list_options VALUES ('refsource','Referral Card','Referral Card', 9,0,0);
297 INSERT INTO list_options VALUES ('refsource','Other'        ,'Other'        ,10,0,0);
298 #EndIf
300 #IfNotRow list_options list_id country
301 INSERT INTO list_options VALUES ('country','USA','USA',1,0,0);
302 #EndIf
304 #IfMissingColumn patient_data contrastart
305 ALTER TABLE patient_data ADD `contrastart` date DEFAULT NULL COMMENT 'Date contraceptives initially used';
306 INSERT INTO layout_options VALUES ('DEM','contrastart','5Stats','Contraceptives Start',9,4,0,10,10,'',1,1,'','D','Date contraceptive services initially provided');
307 #EndIf
309 #IfMissingColumn transactions refer_external
310 ALTER TABLE transactions
311   ADD `refer_external`          tinyint(1)   NOT NULL DEFAULT 0;
312 #EndIf
314 #IfMissingColumn history_data exams
315 ALTER TABLE history_data
316   ADD `exams`      text         NOT NULL DEFAULT '',
317   ADD `usertext11` varchar(255) NOT NULL DEFAULT '',
318   ADD `usertext12` varchar(255) NOT NULL DEFAULT '',
319   ADD `usertext13` varchar(255) NOT NULL DEFAULT '',
320   ADD `usertext14` varchar(255) NOT NULL DEFAULT '',
321   ADD `usertext15` varchar(255) NOT NULL DEFAULT '',
322   ADD `usertext16` varchar(255) NOT NULL DEFAULT '',
323   ADD `usertext17` varchar(255) NOT NULL DEFAULT '',
324   ADD `usertext18` varchar(255) NOT NULL DEFAULT '',
325   ADD `usertext19` varchar(255) NOT NULL DEFAULT '',
326   ADD `usertext20` varchar(255) NOT NULL DEFAULT '',
327   ADD `usertext21` varchar(255) NOT NULL DEFAULT '',
328   ADD `usertext22` varchar(255) NOT NULL DEFAULT '',
329   ADD `usertext23` varchar(255) NOT NULL DEFAULT '',
330   ADD `usertext24` varchar(255) NOT NULL DEFAULT '',
331   ADD `usertext25` varchar(255) NOT NULL DEFAULT '',
332   ADD `usertext26` varchar(255) NOT NULL DEFAULT '',
333   ADD `usertext27` varchar(255) NOT NULL DEFAULT '',
334   ADD `usertext28` varchar(255) NOT NULL DEFAULT '',
335   ADD `usertext29` varchar(255) NOT NULL DEFAULT '',
336   ADD `usertext30` varchar(255) NOT NULL DEFAULT '',
337   ADD `userdate11` date DEFAULT NULL,
338   ADD `userdate12` date DEFAULT NULL,
339   ADD `userdate13` date DEFAULT NULL,
340   ADD `userdate14` date DEFAULT NULL,
341   ADD `userdate15` date DEFAULT NULL;
342 UPDATE history_data SET exams = CONCAT(exams, '|brs:1:', last_breast_exam              ) WHERE SUBSTRING(last_exam_results, 1, 1) = '1';
343 UPDATE history_data SET exams = CONCAT(exams, '|brs:2:', last_breast_exam              ) WHERE SUBSTRING(last_exam_results, 1, 1) = '2';
344 UPDATE history_data SET exams = CONCAT(exams, '|mam:1:', last_mammogram                ) WHERE SUBSTRING(last_exam_results, 2, 1) = '1';
345 UPDATE history_data SET exams = CONCAT(exams, '|mam:2:', last_mammogram                ) WHERE SUBSTRING(last_exam_results, 2, 1) = '2';
346 UPDATE history_data SET exams = CONCAT(exams, '|gyn:1:', last_gynocological_exam       ) WHERE SUBSTRING(last_exam_results, 3, 1) = '1';
347 UPDATE history_data SET exams = CONCAT(exams, '|gyn:2:', last_gynocological_exam       ) WHERE SUBSTRING(last_exam_results, 3, 1) = '2';
348 UPDATE history_data SET exams = CONCAT(exams, '|rec:1:', last_rectal_exam              ) WHERE SUBSTRING(last_exam_results, 4, 1) = '1';
349 UPDATE history_data SET exams = CONCAT(exams, '|rec:2:', last_rectal_exam              ) WHERE SUBSTRING(last_exam_results, 4, 1) = '2';
350 UPDATE history_data SET exams = CONCAT(exams, '|pro:1:', last_prostate_exam            ) WHERE SUBSTRING(last_exam_results, 5, 1) = '1';
351 UPDATE history_data SET exams = CONCAT(exams, '|pro:2:', last_prostate_exam            ) WHERE SUBSTRING(last_exam_results, 5, 1) = '2';
352 UPDATE history_data SET exams = CONCAT(exams, '|phy:1:', last_physical_exam            ) WHERE SUBSTRING(last_exam_results, 6, 1) = '1';
353 UPDATE history_data SET exams = CONCAT(exams, '|phy:2:', last_physical_exam            ) WHERE SUBSTRING(last_exam_results, 6, 1) = '2';
354 UPDATE history_data SET exams = CONCAT(exams, '|sic:1:', last_sigmoidoscopy_colonoscopy) WHERE SUBSTRING(last_exam_results, 7, 1) = '1';
355 UPDATE history_data SET exams = CONCAT(exams, '|sic:2:', last_sigmoidoscopy_colonoscopy) WHERE SUBSTRING(last_exam_results, 7, 1) = '2';
356 UPDATE history_data SET exams = CONCAT(exams, '|ecg:1:', last_ecg                      ) WHERE SUBSTRING(last_exam_results, 8, 1) = '1';
357 UPDATE history_data SET exams = CONCAT(exams, '|ecg:2:', last_ecg                      ) WHERE SUBSTRING(last_exam_results, 8, 1) = '2';
358 UPDATE history_data SET exams = CONCAT(exams, '|cec:1:', last_cardiac_echo             ) WHERE SUBSTRING(last_exam_results, 9, 1) = '1';
359 UPDATE history_data SET exams = CONCAT(exams, '|cec:2:', last_cardiac_echo             ) WHERE SUBSTRING(last_exam_results, 9, 1) = '2';
360 UPDATE history_data SET exams = CONCAT(exams, '|ret:1:', last_retinal                  ) WHERE SUBSTRING(last_exam_results,10, 1) = '1';
361 UPDATE history_data SET exams = CONCAT(exams, '|ret:2:', last_retinal                  ) WHERE SUBSTRING(last_exam_results,10, 1) = '2';
362 UPDATE history_data SET exams = CONCAT(exams, '|flu:1:', last_fluvax                   ) WHERE SUBSTRING(last_exam_results,11, 1) = '1';
363 UPDATE history_data SET exams = CONCAT(exams, '|flu:2:', last_fluvax                   ) WHERE SUBSTRING(last_exam_results,11, 1) = '2';
364 UPDATE history_data SET exams = CONCAT(exams, '|pne:1:', last_pneuvax                  ) WHERE SUBSTRING(last_exam_results,12, 1) = '1';
365 UPDATE history_data SET exams = CONCAT(exams, '|pne:2:', last_pneuvax                  ) WHERE SUBSTRING(last_exam_results,12, 1) = '2';
366 UPDATE history_data SET exams = CONCAT(exams, '|ldl:1:', last_ldl                      ) WHERE SUBSTRING(last_exam_results,13, 1) = '1';
367 UPDATE history_data SET exams = CONCAT(exams, '|ldl:2:', last_ldl                      ) WHERE SUBSTRING(last_exam_results,13, 1) = '2';
368 UPDATE history_data SET exams = CONCAT(exams, '|hem:1:', last_hemoglobin               ) WHERE SUBSTRING(last_exam_results,14, 1) = '1';
369 UPDATE history_data SET exams = CONCAT(exams, '|hem:2:', last_hemoglobin               ) WHERE SUBSTRING(last_exam_results,14, 1) = '2';
370 UPDATE history_data SET exams = CONCAT(exams, '|psa:1:', last_psa                      ) WHERE SUBSTRING(last_exam_results,15, 1) = '1';
371 UPDATE history_data SET exams = CONCAT(exams, '|psa:2:', last_psa                      ) WHERE SUBSTRING(last_exam_results,15, 1) = '2';
372 #EndIf
374 #IfNotRow layout_options form_id HIS
375 DELETE FROM layout_options WHERE form_id = 'HIS' AND group_name = '1General';
376 INSERT INTO layout_options VALUES ('HIS','usertext11','1General','Risk Factors',1,21,1,0,0,'riskfactors',1,1,'','' ,'Risk Factors');
377 INSERT INTO layout_options VALUES ('HIS','exams'     ,'1General','Exams/Tests' ,2,23,1,0,0,'exams'      ,1,1,'','' ,'Exam and test results');
378 DELETE FROM layout_options WHERE form_id = 'HIS' AND group_name = '2Family History';
379 INSERT INTO layout_options VALUES ('HIS','history_father'   ,'2Family History','Father'   ,1, 2,1,20,255,'',1,1,'','' ,'');
380 INSERT INTO layout_options VALUES ('HIS','history_mother'   ,'2Family History','Mother'   ,2, 2,1,20,255,'',1,1,'','' ,'');
381 INSERT INTO layout_options VALUES ('HIS','history_siblings' ,'2Family History','Siblings' ,3, 2,1,20,255,'',1,1,'','' ,'');
382 INSERT INTO layout_options VALUES ('HIS','history_spouse'   ,'2Family History','Spouse'   ,4, 2,1,20,255,'',1,1,'','' ,'');
383 INSERT INTO layout_options VALUES ('HIS','history_offspring','2Family History','Offspring',5, 2,1,20,255,'',1,3,'','' ,'');
384 DELETE FROM layout_options WHERE form_id = 'HIS' AND group_name = '3Relatives';
385 INSERT INTO layout_options VALUES ('HIS','relatives_cancer'             ,'3Relatives','Cancer'             ,1, 2,1,20,255,'',1,1,'','' ,'');
386 INSERT INTO layout_options VALUES ('HIS','relatives_tuberculosis'       ,'3Relatives','Tuberculosis'       ,2, 2,1,20,255,'',1,1,'','' ,'');
387 INSERT INTO layout_options VALUES ('HIS','relatives_diabetes'           ,'3Relatives','Diabetes'           ,3, 2,1,20,255,'',1,1,'','' ,'');
388 INSERT INTO layout_options VALUES ('HIS','relatives_high_blood_pressure','3Relatives','High Blood Pressure',4, 2,1,20,255,'',1,1,'','' ,'');
389 INSERT INTO layout_options VALUES ('HIS','relatives_heart_problems'     ,'3Relatives','Heart Problems'     ,5, 2,1,20,255,'',1,1,'','' ,'');
390 INSERT INTO layout_options VALUES ('HIS','relatives_stroke'             ,'3Relatives','Stroke'             ,6, 2,1,20,255,'',1,1,'','' ,'');
391 INSERT INTO layout_options VALUES ('HIS','relatives_epilepsy'           ,'3Relatives','Epilepsy'           ,7, 2,1,20,255,'',1,1,'','' ,'');
392 INSERT INTO layout_options VALUES ('HIS','relatives_mental_illness'     ,'3Relatives','Mental Illness'     ,8, 2,1,20,255,'',1,1,'','' ,'');
393 INSERT INTO layout_options VALUES ('HIS','relatives_suicide'            ,'3Relatives','Suicide'            ,9, 2,1,20,255,'',1,3,'','' ,'');
394 DELETE FROM layout_options WHERE form_id = 'HIS' AND group_name = '4Lifestyle';
395 INSERT INTO layout_options VALUES ('HIS','coffee'              ,'4Lifestyle','Coffee'              ,1, 2,1,20,255,'',1,1,'','' ,'Caffeine consumption');
396 INSERT INTO layout_options VALUES ('HIS','tobacco'             ,'4Lifestyle','Tobacco'             ,2, 2,1,20,255,'',1,1,'','' ,'Tobacco use');
397 INSERT INTO layout_options VALUES ('HIS','alcohol'             ,'4Lifestyle','Alcohol'             ,3, 2,1,20,255,'',1,1,'','' ,'Alcohol consumption');
398 INSERT INTO layout_options VALUES ('HIS','sleep_patterns'      ,'4Lifestyle','Sleep Patterns'      ,4, 2,1,20,255,'',1,1,'','' ,'Sleep patterns');
399 INSERT INTO layout_options VALUES ('HIS','exercise_patterns'   ,'4Lifestyle','Exercise Patterns'   ,5, 2,1,20,255,'',1,1,'','' ,'Exercise patterns');
400 INSERT INTO layout_options VALUES ('HIS','seatbelt_use'        ,'4Lifestyle','Seatbelt Use'        ,6, 2,1,20,255,'',1,1,'','' ,'Seatbelt use');
401 INSERT INTO layout_options VALUES ('HIS','counseling'          ,'4Lifestyle','Counseling'          ,7, 2,1,20,255,'',1,1,'','' ,'Counseling activities');
402 INSERT INTO layout_options VALUES ('HIS','hazardous_activities','4Lifestyle','Hazardous Activities',8, 2,1,20,255,'',1,1,'','' ,'Hazardous activities');
403 DELETE FROM layout_options WHERE form_id = 'HIS' AND group_name = '5Other';
404 INSERT INTO layout_options VALUES ('HIS','name_1'            ,'5Other','Name/Value'        ,1, 2,1,10,255,'',1,1,'','' ,'Name 1' );
405 INSERT INTO layout_options VALUES ('HIS','value_1'           ,'5Other',''                  ,2, 2,1,10,255,'',0,0,'','' ,'Value 1');
406 INSERT INTO layout_options VALUES ('HIS','name_2'            ,'5Other','Name/Value'        ,3, 2,1,10,255,'',1,1,'','' ,'Name 2' );
407 INSERT INTO layout_options VALUES ('HIS','value_2'           ,'5Other',''                  ,4, 2,1,10,255,'',0,0,'','' ,'Value 2');
408 INSERT INTO layout_options VALUES ('HIS','additional_history','5Other','Additional History',5, 3,1,30,  3,'',1,3,'' ,'' ,'Additional history notes');
409 #EndIf
411 #IfNotRow list_options list_id riskfactors
412 DELETE FROM list_options WHERE list_id = 'riskfactors';
413 INSERT INTO list_options VALUES ('riskfactors','vv' ,'Varicose Veins'                      , 1,0,0);
414 INSERT INTO list_options VALUES ('riskfactors','ht' ,'Hypertension'                        , 2,0,0);
415 INSERT INTO list_options VALUES ('riskfactors','db' ,'Diabetes'                            , 3,0,0);
416 INSERT INTO list_options VALUES ('riskfactors','sc' ,'Sickle Cell'                         , 4,0,0);
417 INSERT INTO list_options VALUES ('riskfactors','fib','Fibroids'                            , 5,0,0);
418 INSERT INTO list_options VALUES ('riskfactors','pid','PID (Pelvic Inflammatory Disease)'   , 6,0,0);
419 INSERT INTO list_options VALUES ('riskfactors','mig','Severe Migraine'                     , 7,0,0);
420 INSERT INTO list_options VALUES ('riskfactors','hd' ,'Heart Disease'                       , 8,0,0);
421 INSERT INTO list_options VALUES ('riskfactors','str','Thrombosis/Stroke'                   , 9,0,0);
422 INSERT INTO list_options VALUES ('riskfactors','hep','Hepatitis'                           ,10,0,0);
423 INSERT INTO list_options VALUES ('riskfactors','gb' ,'Gall Bladder Condition'              ,11,0,0);
424 INSERT INTO list_options VALUES ('riskfactors','br' ,'Breast Disease'                      ,12,0,0);
425 INSERT INTO list_options VALUES ('riskfactors','dpr','Depression'                          ,13,0,0);
426 INSERT INTO list_options VALUES ('riskfactors','all','Allergies'                           ,14,0,0);
427 INSERT INTO list_options VALUES ('riskfactors','inf','Infertility'                         ,15,0,0);
428 INSERT INTO list_options VALUES ('riskfactors','ast','Asthma'                              ,16,0,0);
429 INSERT INTO list_options VALUES ('riskfactors','ep' ,'Epilepsy'                            ,17,0,0);
430 INSERT INTO list_options VALUES ('riskfactors','cl' ,'Contact Lenses'                      ,18,0,0);
431 INSERT INTO list_options VALUES ('riskfactors','coc','Contraceptive Complication (specify)',19,0,0);
432 INSERT INTO list_options VALUES ('riskfactors','oth','Other (specify)'                     ,20,0,0);
433 DELETE FROM list_options WHERE list_id = 'exams';
434 INSERT INTO list_options VALUES ('exams' ,'brs','Breast Exam'          , 1,0,0);
435 INSERT INTO list_options VALUES ('exams' ,'cec','Cardiac Echo'         , 2,0,0);
436 INSERT INTO list_options VALUES ('exams' ,'ecg','ECG'                  , 3,0,0);
437 INSERT INTO list_options VALUES ('exams' ,'gyn','Gynecological Exam'   , 4,0,0);
438 INSERT INTO list_options VALUES ('exams' ,'mam','Mammogram'            , 5,0,0);
439 INSERT INTO list_options VALUES ('exams' ,'phy','Physical Exam'        , 6,0,0);
440 INSERT INTO list_options VALUES ('exams' ,'pro','Prostate Exam'        , 7,0,0);
441 INSERT INTO list_options VALUES ('exams' ,'rec','Rectal Exam'          , 8,0,0);
442 INSERT INTO list_options VALUES ('exams' ,'sic','Sigmoid/Colonoscopy'  , 9,0,0);
443 INSERT INTO list_options VALUES ('exams' ,'ret','Retinal Exam'         ,10,0,0);
444 INSERT INTO list_options VALUES ('exams' ,'flu','Flu Vaccination'      ,11,0,0);
445 INSERT INTO list_options VALUES ('exams' ,'pne','Pneumonia Vaccination',12,0,0);
446 INSERT INTO list_options VALUES ('exams' ,'ldl','LDL'                  ,13,0,0);
447 INSERT INTO list_options VALUES ('exams' ,'hem','Hemoglobin'           ,14,0,0);
448 INSERT INTO list_options VALUES ('exams' ,'psa','PSA'                  ,15,0,0);
449 DELETE FROM list_options WHERE list_id = 'lists';
450 INSERT INTO list_options VALUES ('lists' ,'boolean'    ,'Boolean'            , 1,0,0);
451 INSERT INTO list_options VALUES ('lists' ,'country'    ,'Country'            , 2,0,0);
452 INSERT INTO list_options VALUES ('lists' ,'feesheet'   ,'Fee Sheet'          , 3,0,0);
453 INSERT INTO list_options VALUES ('lists' ,'language'   ,'Language'           , 4,0,0);
454 INSERT INTO list_options VALUES ('lists' ,'marital'    ,'Marital Status'     , 5,0,0);
455 INSERT INTO list_options VALUES ('lists' ,'pricelevel' ,'Price Level'        , 6,0,0);
456 INSERT INTO list_options VALUES ('lists' ,'ethrace'    ,'Race/Ethnicity'     , 7,0,0);
457 INSERT INTO list_options VALUES ('lists' ,'refsource'  ,'Referral Source'    , 8,0,0);
458 INSERT INTO list_options VALUES ('lists' ,'risklevel'  ,'Risk Level'         , 9,0,0);
459 INSERT INTO list_options VALUES ('lists' ,'superbill'  ,'Service Category'   ,10,0,0);
460 INSERT INTO list_options VALUES ('lists' ,'sex'        ,'Sex'                ,11,0,0);
461 INSERT INTO list_options VALUES ('lists' ,'taxrate'    ,'Tax Rate'           ,13,0,0);
462 INSERT INTO list_options VALUES ('lists' ,'titles'     ,'Titles'             ,14,0,0);
463 INSERT INTO list_options VALUES ('lists' ,'yesno'      ,'Yes/No'             ,15,0,0);
464 INSERT INTO list_options VALUES ('lists' ,'userlist1'  ,'User Defined List 1',16,0,0);
465 INSERT INTO list_options VALUES ('lists' ,'userlist2'  ,'User Defined List 2',17,0,0);
466 INSERT INTO list_options VALUES ('lists' ,'userlist3'  ,'User Defined List 3',18,0,0);
467 INSERT INTO list_options VALUES ('lists' ,'userlist4'  ,'User Defined List 4',19,0,0);
468 INSERT INTO list_options VALUES ('lists' ,'userlist5'  ,'User Defined List 5',20,0,0);
469 INSERT INTO list_options VALUES ('lists' ,'userlist6'  ,'User Defined List 6',21,0,0);
470 INSERT INTO list_options VALUES ('lists' ,'userlist7'  ,'User Defined List 7',22,0,0);
471 INSERT INTO list_options VALUES ('lists' ,'riskfactors','Risk Factors'       ,23,0,0);
472 INSERT INTO list_options VALUES ('lists' ,'exams'      ,'Exams/Tests'        ,24,0,0);
473 #EndIf
475 #IfMissingColumn patient_data hipaa_allowsms
476 ALTER TABLE patient_data
477   ADD hipaa_allowsms   varchar(3) NOT NULL DEFAULT 'NO',
478   ADD hipaa_allowemail varchar(3) NOT NULL DEFAULT 'NO';
479 INSERT INTO `layout_options` VALUES ('DEM', 'hipaa_allowsms'  , '3Choices', 'Allow SMS'  , 5, 1, 1, 0, 0, 'yesno', 1, 1, '', '', 'Allow SMS (text messages)?');
480 INSERT INTO `layout_options` VALUES ('DEM', 'hipaa_allowemail', '3Choices', 'Allow Email', 5, 1, 1, 0, 0, 'yesno', 1, 1, '', '', 'Allow Email?');
481 #EndIf
483 #IfNotRow list_options list_id drug_form
484 INSERT INTO list_options VALUES ('drug_form','1','suspension' ,1,0,0);
485 INSERT INTO list_options VALUES ('drug_form','2','tablet'     ,2,0,0);
486 INSERT INTO list_options VALUES ('drug_form','3','capsule'    ,3,0,0);
487 INSERT INTO list_options VALUES ('drug_form','4','solution'   ,4,0,0);
488 INSERT INTO list_options VALUES ('drug_form','5','tsp'        ,5,0,0);
489 INSERT INTO list_options VALUES ('drug_form','6','ml'         ,6,0,0);
490 INSERT INTO list_options VALUES ('drug_form','7','units'      ,7,0,0);
491 INSERT INTO list_options VALUES ('drug_form','8','inhalations',8,0,0);
492 INSERT INTO list_options VALUES ('drug_form','9','gtts(drops)',9,0,0);
493 INSERT INTO list_options VALUES ('drug_units','1','mg'    ,1,0,0);
494 INSERT INTO list_options VALUES ('drug_units','2','mg/1cc',2,0,0);
495 INSERT INTO list_options VALUES ('drug_units','3','mg/2cc',3,0,0);
496 INSERT INTO list_options VALUES ('drug_units','4','mg/3cc',4,0,0);
497 INSERT INTO list_options VALUES ('drug_units','5','mg/4cc',5,0,0);
498 INSERT INTO list_options VALUES ('drug_units','6','mg/5cc',6,0,0);
499 INSERT INTO list_options VALUES ('drug_units','7','grams' ,7,0,0);
500 INSERT INTO list_options VALUES ('drug_units','8','mcg'   ,8,0,0);
501 INSERT INTO list_options VALUES ('drug_route', '1','Per Oris'         , 1,0,0);
502 INSERT INTO list_options VALUES ('drug_route', '2','Per Rectum'       , 2,0,0);
503 INSERT INTO list_options VALUES ('drug_route', '3','To Skin'          , 3,0,0);
504 INSERT INTO list_options VALUES ('drug_route', '4','To Affected Area' , 4,0,0);
505 INSERT INTO list_options VALUES ('drug_route', '5','Sublingual'       , 5,0,0);
506 INSERT INTO list_options VALUES ('drug_route',' 6','OS'               , 6,0,0);
507 INSERT INTO list_options VALUES ('drug_route', '7','OD'               , 7,0,0);
508 INSERT INTO list_options VALUES ('drug_route', '8','OU'               , 8,0,0);
509 INSERT INTO list_options VALUES ('drug_route', '9','SQ'               , 9,0,0);
510 INSERT INTO list_options VALUES ('drug_route','10','IM'               ,10,0,0);
511 INSERT INTO list_options VALUES ('drug_route','11','IV'               ,11,0,0);
512 INSERT INTO list_options VALUES ('drug_route','12','Per Nostril'      ,12,0,0);
513 INSERT INTO list_options VALUES ('drug_interval','1','b.i.d.',1,0,0);
514 INSERT INTO list_options VALUES ('drug_interval','2','t.i.d.',2,0,0);
515 INSERT INTO list_options VALUES ('drug_interval','3','q.i.d.',3,0,0);
516 INSERT INTO list_options VALUES ('drug_interval','4','q.3h'  ,4,0,0);
517 INSERT INTO list_options VALUES ('drug_interval','5','q.4h'  ,5,0,0);
518 INSERT INTO list_options VALUES ('drug_interval','6','q.5h'  ,6,0,0);
519 INSERT INTO list_options VALUES ('drug_interval','7','q.6h'  ,7,0,0);
520 INSERT INTO list_options VALUES ('drug_interval','8','q.8h'  ,8,0,0);
521 INSERT INTO list_options VALUES ('drug_interval','9','q.d.'  ,9,0,0);
522 INSERT INTO list_options VALUES ('lists' ,'drug_form'    ,'Drug Forms'    ,24,0,0);
523 INSERT INTO list_options VALUES ('lists' ,'drug_units'   ,'Drug Units'    ,25,0,0);
524 INSERT INTO list_options VALUES ('lists' ,'drug_route'   ,'Drug Routes'   ,26,0,0);
525 INSERT INTO list_options VALUES ('lists' ,'drug_interval','Drug Intervals',27,0,0);
526 #EndIf
528 #IfMissingColumn drugs cyp_factor
529 ALTER TABLE drugs
530   ADD cyp_factor float NOT NULL DEFAULT 0 COMMENT 'quantity representing a years supply';
531 #EndIf
533 #IfMissingColumn codes cyp_factor
534 ALTER TABLE codes
535   ADD cyp_factor float NOT NULL DEFAULT 0 COMMENT 'quantity representing a years supply';
536 #EndIf
538 #IfNotRow list_options list_id state
539 INSERT INTO list_options VALUES ('state','CA','California',1,0,0);
540 INSERT INTO list_options VALUES ('lists' ,'state','State',12,0,0);
541 UPDATE layout_options SET data_type = 1, list_id = 'state' WHERE form_id = 'DEM' AND field_id = 'state';
542 #EndIf
544 #IfMissingColumn transactions refer_related_code
545 ALTER TABLE transactions
546   ADD refer_related_code varchar(255) NOT NULL DEFAULT '' COMMENT 'may reference codes.code as referral reason';
547 INSERT INTO layout_options VALUES ('REF','refer_related_code','1Referral','Requested Service',8,15,1,30,255,'',1,1,'','','Billing Code for Requested Service');
548 #EndIf
550 #IfNotColumnType billing fee decimal(12,2)
551 ALTER TABLE billing
552   MODIFY `fee` decimal(12,2) NOT NULL DEFAULT 0.00;
553 ALTER TABLE codes
554   MODIFY `fee` decimal(12,2) NOT NULL DEFAULT 0.00;
555 ALTER TABLE drug_sales
556   MODIFY `fee` decimal(12,2) NOT NULL DEFAULT 0.00;
557 ALTER TABLE payments
558   MODIFY `amount1` decimal(12,2) NOT NULL DEFAULT 0.00,
559   MODIFY `amount2` decimal(12,2) NOT NULL DEFAULT 0.00,
560   MODIFY `posted1` decimal(12,2) NOT NULL DEFAULT 0.00,
561   MODIFY `posted2` decimal(12,2) NOT NULL DEFAULT 0.00;
562 #EndIf
564 #IfMissingColumn users taxonomy
565 ALTER TABLE users
566   ADD `taxonomy` varchar(30) NOT NULL DEFAULT '207Q00000X';
567 #EndIf
569 #IfMissingColumn patient_data usertext3
570 ALTER TABLE patient_data
571   ADD `usertext3` varchar(255) NOT NULL DEFAULT '',
572   ADD `usertext4` varchar(255) NOT NULL DEFAULT '',
573   ADD `usertext5` varchar(255) NOT NULL DEFAULT '',
574   ADD `usertext6` varchar(255) NOT NULL DEFAULT '',
575   ADD `usertext7` varchar(255) NOT NULL DEFAULT '',
576   ADD `usertext8` varchar(255) NOT NULL DEFAULT '';
577 INSERT INTO layout_options VALUES ('DEM','usertext3','6Misc','User Defined Text 3', 3,2,0,10,63,'',1,1,'','','User Defined');
578 INSERT INTO layout_options VALUES ('DEM','usertext4','6Misc','User Defined Text 4', 4,2,0,10,63,'',1,1,'','','User Defined');
579 INSERT INTO layout_options VALUES ('DEM','usertext5','6Misc','User Defined Text 5', 5,2,0,10,63,'',1,1,'','','User Defined');
580 INSERT INTO layout_options VALUES ('DEM','usertext6','6Misc','User Defined Text 6', 6,2,0,10,63,'',1,1,'','','User Defined');
581 INSERT INTO layout_options VALUES ('DEM','usertext7','6Misc','User Defined Text 7', 7,2,0,10,63,'',1,1,'','','User Defined');
582 INSERT INTO layout_options VALUES ('DEM','usertext8','6Misc','User Defined Text 8', 8,2,0,10,63,'',1,1,'','','User Defined');
583 #EndIf
585 #IfMissingColumn history_data userarea11
586 ALTER TABLE history_data
587   ADD `userarea11` text NOT NULL DEFAULT '',
588   ADD `userarea12` text NOT NULL DEFAULT '';
589 INSERT INTO layout_options VALUES ('HIS','userarea11','5Other','User Defined Area 11',6,3,0,30,3,'',1,3,'','','User Defined');
590 INSERT INTO layout_options VALUES ('HIS','userarea12','5Other','User Defined Area 12',7,3,0,30,3,'',1,3,'','','User Defined');
591 #EndIf