'Lists' use developer proposal

bradymiller wrote on Tuesday, July 07, 2009:

hey,

After banging head against wall, I’ve come to the conclusion that there is no way for me to increment through the ‘seq’ column to order the data. So upgraders will get a zero in every seq column. To avoid things looking messy I’ll place a second sort (after the seq sort) in the mysql queries in options.inc.php and admin lists queries. Thus will sort by seq primarily, but use the title names as secondary sort of seq are equal. 

Unless the mysql master (Rod) knows a way for me to increment through the ‘seq’ column during the upgrade script.

-brady

sunsetsystems wrote on Tuesday, July 07, 2009:

Brady I’m making some other changes to options.inc.php right now, so I’ll make this change in that module for you.

Rod
www.sunsetsystems.com

bradymiller wrote on Tuesday, July 07, 2009:

hey,
Thanks. I just committed the changes to CVS for migration of immunization table to lists. The immunization table is no more. Here’s the files I touched:
openemr/interface/super/edit_list.php
openemr/sql/3_0_1-to-3_0_2_upgrade.sql
openemr/sql/database.sql
openemr/interface/patient_file/summary/immunizations.php
openemr/interface/patient_file/summary/stats.php
openemr/interface/patient_file/report/custom_report.php
openemr/interface/patient_file/report/full_report.php
openemr/interface/patient_file/summary/shot_record.php
openemr/interface/patient_file/encounter/cash_receipt.php

-brady

bradymiller wrote on Thursday, July 09, 2009:

Hey,

Now working on the drugs/prescriptions lists and migration with the drug module and openemr’ prescriptions. Just wanted to get confirmation on the plan to deal with the upgrade sql script.

There are two bugs with the current drug lists, which were discussed above. The gram-microgram bug is nasty because if you choose grams in the drug module it then shows up in prescriptions as mcg and vice versa. So here are proposed fixes to the upgrade sql script:
UPDATE list_options SET option_id = ‘6’ WHERE option_id = ’ 6’ and list_id = ‘drug_route’;
UPDATE list_options SET title = ‘mcg’ WHERE option_id = ‘7’ and list_id = ‘drug_units’;
UPDATE list_options SET title = ‘grams’ WHERE option_id = ‘8’ and list_id = ‘drug_units’;

The following will be added to the upgrade script to add missing items (including blanks):
INSERT INTO list_options VALUES (‘drug_form’,‘0’,’’           , 0,0,0);
INSERT INTO list_options VALUES (‘drug_form’,‘10’,‘cream’     ,10,0,0);
INSERT INTO list_options VALUES (‘drug_form’,‘11’,‘ointment’  ,11,0,0);
INSERT INTO list_options VALUES (‘drug_units’,‘0’,’’          , 0,0,0);
INSERT INTO list_options VALUES (‘drug_route’, ‘0’,’’         , 0,0,0);
INSERT INTO list_options VALUES (‘drug_route’,‘13’,‘Both Ears’,13,0,0);
INSERT INTO list_options VALUES (‘drug_route’,‘14’,‘Left Ear’ ,14,0,0);
INSERT INTO list_options VALUES (‘drug_route’,‘15’,‘Right Ear’,15,0,0);
INSERT INTO list_options VALUES (‘drug_interval’,‘0’,’’       , 0,0,0);
INSERT INTO list_options VALUES (‘drug_interval’,‘10’,‘a.c.’  ,10,0,0);
INSERT INTO list_options VALUES (‘drug_interval’,‘11’,‘p.c.’  ,11,0,0);
INSERT INTO list_options VALUES (‘drug_interval’,‘12’,‘a.m.’  ,12,0,0);
INSERT INTO list_options VALUES (‘drug_interval’,‘13’,‘p.m.’  ,13,0,0);
INSERT INTO list_options VALUES (‘drug_interval’,‘14’,‘ante’  ,14,0,0);
INSERT INTO list_options VALUES (‘drug_interval’,‘15’,‘h’     ,15,0,0);
INSERT INTO list_options VALUES (‘drug_interval’,‘16’,‘h.s.’  ,16,0,0);
INSERT INTO list_options VALUES (‘drug_interval’,‘17’,‘p.r.n.’,17,0,0);
INSERT INTO list_options VALUES (‘drug_interval’,‘18’,‘stat’  ,18,0,0);

Should I be surrounding these by anything the upgrade script to ensure don’t overwrite (possibly create items with identical id’s also) an upgraders customized values (these shouldn’t be very customized anyways since these are being used in drug module and required to be consistent with prescriptions values which are hard-coded (the hard-coding is soon to be a thing of the past hopefully).

At this point, I’m done integrating changes into drug module (about 11 files modified), and now working on integrating this into the prescription stuff.

-brady

sunsetsystems wrote on Thursday, July 09, 2009:

Hi Brady, offhand that looks OK.  I do suggest surrounding those inserts with a check to make sure there is no duplication… just to be extra careful.

Rod
www.sunsetsystems.com

bradymiller wrote on Thursday, July 09, 2009:

Rod,

To do a good check in the upgrade to avoid duplicates of the inserts, I was forced to create another function in sql_upgrade.php (basically checks for two things in where clause instead of one). Couldn’t figure out a better way:
function tableHasRow2D($tblname, $colname, $value, $colname2, $value2)

Then the upgrade script looks like this:

#IfNotRow2D list_options list_id drug_form option_id 0
INSERT INTO list_options VALUES (‘drug_form’    ,‘0’ ,’’         , 0,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_form option_id 10
INSERT INTO list_options VALUES (‘drug_form’    ,‘10’,‘cream’    ,10,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_form option_id 11
INSERT INTO list_options VALUES (‘drug_form’    ,‘11’,‘ointment’ ,11,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_units option_id 0
INSERT INTO list_options VALUES (‘drug_units’   ,‘0’ ,’’         , 0,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_route option_id 0
INSERT INTO list_options VALUES (‘drug_route’   ,‘0’ ,’’         , 0,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_route option_id 13
INSERT INTO list_options VALUES (‘drug_route’   ,‘13’,‘Both Ears’,13,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_route option_id 14
INSERT INTO list_options VALUES (‘drug_route’   ,‘14’,‘Left Ear’ ,14,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_route option_id 15
INSERT INTO list_options VALUES (‘drug_route’   ,‘15’,‘Right Ear’,15,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_interval option_id 0
INSERT INTO list_options VALUES (‘drug_interval’,‘0’ ,’’         , 0,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_interval option_id 10
INSERT INTO list_options VALUES (‘drug_interval’,‘10’,‘a.c.’     ,10,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_interval option_id 11
INSERT INTO list_options VALUES (‘drug_interval’,‘11’,‘p.c.’     ,11,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_interval option_id 12
INSERT INTO list_options VALUES (‘drug_interval’,‘12’,‘a.m.’     ,12,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_interval option_id 13
INSERT INTO list_options VALUES (‘drug_interval’,‘13’,‘p.m.’     ,13,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_interval option_id 14
INSERT INTO list_options VALUES (‘drug_interval’,‘14’,‘ante’     ,14,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_interval option_id 15
INSERT INTO list_options VALUES (‘drug_interval’,‘15’,‘h’        ,15,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_interval option_id 16
INSERT INTO list_options VALUES (‘drug_interval’,‘16’,‘h.s.’     ,16,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_interval option_id 17
INSERT INTO list_options VALUES (‘drug_interval’,‘17’,‘p.r.n.’   ,17,0,0);
#EndIf
#IfNotRow2D list_options list_id drug_interval option_id 18
INSERT INTO list_options VALUES (‘drug_interval’,‘18’,‘stat’     ,18,0,0);
#EndIf

-brady

sunsetsystems wrote on Thursday, July 09, 2009:

Thanks Brady!

Rod
www.sunsetsystems.com

bradymiller wrote on Friday, July 10, 2009:

hey,

Done and committed.

Both prescriptions and the drug module are now using the form, route, interval, and units lists. Pretty nifty, Although commented out, I placed all the default entries along with ID numbers into the openemr/library/classes/Prescription.class.php file. This is a good place to keep track of the default entries in case a user by chance screws up their lists and for us to keep track if we add anymore to the default set up.

For your drug module, Rod, I removed your load_drug_attributes function mechanism and have all related stuff using the functions in options.inc.php, so then have access to the validations in those functions and opens up possibility for widgets on those forms in the future.

For the prescription stuff I actually copied your load_drug_attributes function mechanism over there to get it to work quickly with the lists, which it does nicely. Hopefully, at some point I’ll also get the prescription stuff to use the options.inc.php functions to leverage its validation and options for widgets in the future.

Files I touched:
openemr/interface/drugs/add_edit_drug.php
openemr/interface/drugs/add_edit_lot.php
openemr/interface/drugs/destroy_lot.php
openemr/interface/drugs/dispense_drug.php
openemr/interface/drugs/drug_inventory.php
openemr/interface/drugs/drugs.inc.php
openemr/interface/reports/destroyed_drugs_report.php
openemr/interface/reports/inventory_list.php
openemr/interface/reports/prescriptions_report.php
openemr/library/classes/Prescription.class.php
openemr/sql/3_0_1-to-3_0_2_upgrade.sql
openemr/sql/database.sql
openemr/sql_upgrade.php

-brady