diff --git a/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-0.00-11.10.sql b/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-0.00-11.10.sql index c3a1d5c9d..b383e2079 100644 --- a/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-0.00-11.10.sql +++ b/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-0.00-11.10.sql @@ -34,10 +34,12 @@ CREATE TABLE Viral_Load_Assay.assays -- ---------------------------- -- Records of assays -- ---------------------------- +-- @SkipOnEmptySchemasBegin INSERT INTO Viral_Load_Assay.assays (assayName, virus) VALUES ('SIVmac239-Gag', 'SIVmac239'); +-- @SkipOnEmptySchemasEnd -- ---------------------------- -- Table structure for vl_category @@ -71,8 +73,10 @@ WITH (OIDS=FALSE); -- ---------------------------- -- Records of vl_instrument -- ---------------------------- +-- @SkipOnEmptySchemasBegin INSERT INTO Viral_Load_Assay.vl_instrument VALUES ('LC480'); INSERT INTO Viral_Load_Assay.vl_instrument VALUES ('Light Cycler'); +-- @SkipOnEmptySchemasEnd -- ---------------------------- -- Table structure for vl_sampletype @@ -105,7 +109,9 @@ WITH (OIDS=FALSE); -- ---------------------------- -- Records of vl_technique -- ---------------------------- +-- @SkipOnEmptySchemasBegin INSERT INTO Viral_Load_Assay.vl_technique VALUES ('Lifson 1-Step VL'); +-- @SkipOnEmptySchemasEnd -- ---------------------------- -- Table structure for vl_virus @@ -122,5 +128,3 @@ WITH (OIDS=FALSE); -- Records of vl_virus -- ---------------------------- INSERT INTO Viral_Load_Assay.vl_virus VALUES ('SIVmac239'); - - diff --git a/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.20-12.21.sql b/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.20-12.21.sql index dafce96d8..4f75f746b 100644 --- a/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.20-12.21.sql +++ b/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.20-12.21.sql @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +-- @SkipOnEmptySchemasBegin INSERT INTO viral_load_assay.vl_instrument VALUES ('ABI 7500'); +-- @SkipOnEmptySchemasEnd DROP TABLE viral_load_assay.vl_category; \ No newline at end of file diff --git a/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.22-12.23.sql b/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.22-12.23.sql index 717593570..3c2d3eb6e 100644 --- a/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.22-12.23.sql +++ b/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.22-12.23.sql @@ -13,4 +13,6 @@ CREATE TABLE viral_load_assay.fluors ( constraint PK_fluors PRIMARY KEY (name) ); -INSERT INTO viral_load_assay.fluors (name) VALUES ('FAM'); \ No newline at end of file +-- @SkipOnEmptySchemasBegin +INSERT INTO viral_load_assay.fluors (name) VALUES ('FAM'); +-- @SkipOnEmptySchemasEnd diff --git a/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.26-12.27.sql b/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.26-12.27.sql index 54b19fe71..48199fdfb 100644 --- a/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.26-12.27.sql +++ b/Viral_Load_Assay/resources/schemas/dbscripts/postgresql/Viral_Load_Assay-12.26-12.27.sql @@ -1,6 +1,8 @@ +-- @SkipOnEmptySchemasBegin INSERT INTO viral_load_assay.vl_instrument (instrument) SELECT 'LC96' WHERE NOT EXISTS ( SELECT instrument FROM viral_load_assay.vl_instrument WHERE instrument = 'LC96' - ); \ No newline at end of file + ); +-- @SkipOnEmptySchemasEnd diff --git a/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ViralLoadAssayDataProvider.java b/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ViralLoadAssayDataProvider.java index 9af47f947..80833af2a 100644 --- a/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ViralLoadAssayDataProvider.java +++ b/Viral_Load_Assay/src/org/labkey/viral_load_assay/assay/ViralLoadAssayDataProvider.java @@ -34,12 +34,6 @@ import java.util.List; import java.util.Set; -/** - * Created with IntelliJ IDEA. - * User: bimber - * Date: 9/28/12 - * Time: 4:17 PM - */ public class ViralLoadAssayDataProvider extends AbstractAssayDataProvider { public ViralLoadAssayDataProvider(Module m) diff --git a/ehr/resources/schemas/dbscripts/postgresql/ehr-0.000-24.000.sql b/ehr/resources/schemas/dbscripts/postgresql/ehr-0.000-24.000.sql index ca1713578..58a2f6f80 100644 --- a/ehr/resources/schemas/dbscripts/postgresql/ehr-0.000-24.000.sql +++ b/ehr/resources/schemas/dbscripts/postgresql/ehr-0.000-24.000.sql @@ -276,6 +276,7 @@ CREATE TABLE ehr.notificationTypes CONSTRAINT PK_notificationTypes PRIMARY KEY (NotificationType) ); +-- @SkipOnEmptySchemasBegin INSERT into ehr.notificationTypes (NotificationType, description) VALUES @@ -285,6 +286,7 @@ VALUES ('Animal Care Service Request', ''), ('Colony Validation - General', 'Subscribing to this notification will result in emails for general colony records issues like records needing attention, animals missing from the demographics table, etc.') ; +-- @SkipOnEmptySchemasEnd CREATE TABLE ehr.notificationRecipients ( @@ -407,6 +409,7 @@ CREATE TABLE ehr.qcStateMetadata CONSTRAINT PK_qcStateMetadata PRIMARY KEY (QCStateLabel) ); +-- @SkipOnEmptySchemasBegin INSERT INTO ehr.qcStateMetadata (QCStateLabel,draftData,isDeleted,isRequest) VALUES @@ -421,6 +424,7 @@ VALUES ('Request: Approved', TRUE, FALSE, TRUE), ('Request: Complete', FALSE, FALSE, TRUE) ; +-- @SkipOnEmptySchemasEnd DROP TABLE IF EXISTS ehr.module_properties; @@ -507,12 +511,14 @@ ALTER TABLE ehr.reports add column description varchar(4000) ; +-- @SkipOnEmptySchemasBegin INSERT INTO ehr.qcStateMetadata (QCStateLabel,draftData,isDeleted,isRequest) VALUES ('Completed', FALSE, FALSE, FALSE), ('Scheduled', TRUE, FALSE, FALSE) ; +-- @SkipOnEmptySchemasEnd ALTER TABLE ehr.formTypes ADD COLUMN configJson text; @@ -601,6 +607,7 @@ ALTER table ehr.qcStateMetadata DELETE from ehr.qcStateMetadata; +-- @SkipOnEmptySchemasBegin INSERT INTO ehr.qcStateMetadata (QCStateLabel,DraftData,isDeleted,isRequest,allowFutureDates) VALUES @@ -616,6 +623,7 @@ VALUES ('Request: Complete', FALSE, FALSE, TRUE, TRUE), ('Scheduled', TRUE, FALSE, FALSE, TRUE) ; +-- @SkipOnEmptySchemasEnd UPDATE ehr.qcStateMetadata SET DraftData = FALSE @@ -625,10 +633,12 @@ ALTER table ehr.reports add column sort_order integer ; +-- @SkipOnEmptySchemasBegin insert into ehr.notificationtypes (notificationtype,description) VALUES ('Incompleted Treatments', 'An email will be sent each day at 8:30, 15:30 and 20:30 notifying of any incompleted treatments') ; +-- @SkipOnEmptySchemasEnd CREATE TABLE ehr.automatic_alerts ( rowid serial not null, @@ -685,6 +695,7 @@ UPDATE ehr.qcStateMetadata SET DraftData = TRUE WHERE QCStateLabel = 'Review Requested'; +-- @SkipOnEmptySchemasBegin insert into ehr.notificationtypes (notificationtype,description) VALUES ('Blood Draw Request Completed', 'An email will be sent each time a blood draw request is completed'), @@ -692,6 +703,7 @@ insert into ehr.notificationtypes ('Clinpath Request Completed', 'An email will be sent each time a clinpath request is completed'), ('Clinpath Request Denied', 'An email will be sent each time a clinpath request is denied') ; +-- @SkipOnEmptySchemasEnd alter TABLE ehr.notificationRecipients add column Recipient2 integer @@ -779,10 +791,12 @@ alter TABLE ehr.protocol add column maxAnimals integer ; +-- @SkipOnEmptySchemasBegin insert into ehr.notificationtypes (notificationtype,description) VALUES ('Prenatal Death', 'An email will be sent each time a prenatal death is reported') ; +-- @SkipOnEmptySchemasEnd delete from ehr.notificationtypes where notificationtype in ( 'Clinpath Abnormal Results', @@ -803,6 +817,7 @@ delete from ehr.notificationtypes where notificationtype in ( delete from ehr.notificationtypes where notificationtype = 'Colony Validation - General'; +-- @SkipOnEmptySchemasBegin insert into ehr.notificationtypes (notificationtype,description) VALUES ('Clinpath Abnormal Results', 'An email will be sent periodically to summarize abnormal clinpath results'), @@ -819,6 +834,7 @@ insert into ehr.notificationtypes ('Overdue Weight Alerts', 'An email will be sent daily to summarize animals overdue for weights.'), ('Site Error Alerts', 'An hourly email will be sent if a new site error is reported.') ; +-- @SkipOnEmptySchemasEnd drop TABLE ehr.client_errors; @@ -1263,8 +1279,10 @@ ALTER TABLE ehr.reports ADD subjectIdFieldName varchar(200); ALTER TABLE ehr.project ADD alwaysavailable bool; +-- @SkipOnEmptySchemasBegin INSERT INTO ehr.qcstateMetadata (QCStateLabel,draftData,isDeleted,isRequest) VALUES ('Request: Sample Delivered', TRUE, FALSE, TRUE); +-- @SkipOnEmptySchemasEnd CREATE TABLE ehr.protocolexemptions ( rowid SERIAL, @@ -1337,7 +1355,9 @@ CREATE INDEX snomed_tags_taskid ON ehr.snomed_tags (taskid); CREATE INDEX treatment_times_container_treatmentid ON ehr.treatment_times (container, treatmentid); +-- @SkipOnEmptySchemasBegin INSERT INTO ehr.qcStateMetadata (QCStateLabel,DraftData,isDeleted,isRequest,allowFutureDates) VALUES ('Request: Cancelled', false, false, true, true); +-- @SkipOnEmptySchemasEnd ALTER TABLE ehr.project ADD projecttype varchar(100); @@ -1634,6 +1654,7 @@ DROP FUNCTION ehr.handleAddContactToProtocol(); DELETE FROM ehr.qcStateMetadata WHERE QCStateLabel = 'Started'; DELETE FROM ehr.status WHERE Label = 'Started'; +-- @SkipOnEmptySchemasBegin INSERT INTO ehr.qcStateMetadata (QCStateLabel,draftData,isDeleted,isRequest) VALUES @@ -1642,7 +1663,7 @@ INSERT INTO ehr.status (label,Description,PublicData,DraftData,isDeleted,isRequest,allowFutureDates) VALUES ('Started', 'Record has started, but not completed',TRUE,FALSE,FALSE,FALSE,FALSE); - +-- @SkipOnEmptySchemasEnd -- ehr-17.21-17.22.sql -- contents of ehr-17.21-17.22.sql script are not in rolled up ehr-0.00-18.10.sql, since they got added and merged after the rollup. @@ -1781,6 +1802,7 @@ DROP FUNCTION ehr.addConstraintToFormFrameworkTypes(); DELETE FROM ehr.qcStateMetadata WHERE QCStateLabel = 'Request: On Hold'; DELETE FROM ehr.status WHERE Label = 'Request: On Hold'; +-- @SkipOnEmptySchemasBegin INSERT INTO ehr.qcStateMetadata (QCStateLabel, draftData, isDeleted, isRequest, allowFutureDates) VALUES @@ -1790,6 +1812,7 @@ INSERT INTO ehr.status (label, description, publicData, draftData, isDeleted, isRequest, allowFutureDates) VALUES ('Request: On Hold', 'Request has been put on hold', FALSE, FALSE, FALSE, TRUE, TRUE); +-- @SkipOnEmptySchemasEnd CREATE INDEX snomed_tags_recordid ON ehr.snomed_tags (recordid); diff --git a/ehr/resources/schemas/dbscripts/postgresql/ehr_lookups-0.000-23.000.sql b/ehr/resources/schemas/dbscripts/postgresql/ehr_lookups-0.000-23.000.sql index f4f436547..fbf5c7e37 100644 --- a/ehr/resources/schemas/dbscripts/postgresql/ehr_lookups-0.000-23.000.sql +++ b/ehr/resources/schemas/dbscripts/postgresql/ehr_lookups-0.000-23.000.sql @@ -3345,6 +3345,7 @@ WITH (OIDS=FALSE) -- ---------------------------- -- Records of months -- ---------------------------- +-- @SkipOnEmptySchemasBegin INSERT into ehr_lookups.months (month) VALUES ('January'), ('February'), @@ -3358,7 +3359,7 @@ INSERT into ehr_lookups.months (month) VALUES ('October'), ('November'), ('December'); - +-- @SkipOnEmptySchemasEnd -- ---------------------------- @@ -3807,9 +3808,11 @@ WITH (OIDS=FALSE) -- ---------------------------- -- Records of tb_eye -- ---------------------------- +-- @SkipOnEmptySchemasBegin INSERT INTO ehr_lookups.tb_eye VALUES ('b', 'Both'); INSERT INTO ehr_lookups.tb_eye VALUES ('l', 'Left'); INSERT INTO ehr_lookups.tb_eye VALUES ('r', 'Right'); +-- @SkipOnEmptySchemasEnd -- ---------------------------- -- Table structure for tb_result @@ -3992,9 +3995,11 @@ WITH (OIDS=FALSE) -- ---------------------------- -- Records of yesno -- ---------------------------- +-- @SkipOnEmptySchemasBegin INSERT INTO ehr_lookups.yesno VALUES ('Yes'); INSERT INTO ehr_lookups.yesno VALUES ('No'); INSERT INTO ehr_lookups.yesno VALUES ('NA'); +-- @SkipOnEmptySchemasEnd @@ -4443,13 +4448,14 @@ WITH (OIDS=FALSE) -- ---------------------------- -- Records of normal_abnormal -- ---------------------------- +-- @SkipOnEmptySchemasBegin INSERT INTO ehr_lookups.normal_abnormal (state) VALUES ('Normal'), ('Abnormal') ; - +-- @SkipOnEmptySchemasEnd -- ---------------------------- -- Table structure for observations_anesthesia_recovery @@ -4620,12 +4626,14 @@ WITH (OIDS=FALSE) ; +-- @SkipOnEmptySchemasBegin INSERT INTO ehr_lookups.oor_indicators (indicator) VALUES ('<'), ('>') ; +-- @SkipOnEmptySchemasEnd INSERT INTO ehr_lookups.blood_draw_services (service) VALUES @@ -5009,13 +5017,14 @@ WITH (OIDS=FALSE) ; +-- @SkipOnEmptySchemasBegin INSERT INTO ehr_lookups.qualitative_results (result) VALUES ('Positive'), ('Negative'), ('Indeterminate') ; - +-- @SkipOnEmptySchemasEnd DROP TABLE IF EXISTS ehr_lookups.urine_method; -- ---------------------------- @@ -7031,11 +7040,12 @@ update ehr_lookups.lab_test_range set type = 'Chemistry' where test = 'UA'; update ehr_lookups.lab_test_range set type = 'Hematology' where test = 'WBC'; delete from ehr.notificationtypes where notificationtype = 'Animal Death'; +-- @SkipOnEmptySchemasBegin insert into ehr.notificationtypes (notificationtype,description) VALUES ('Animal Death', 'An email will be sent each time an animal is marked as dead') ; - +-- @SkipOnEmptySchemasEnd -- ---------------------------- -- Table structure for ehr_lookups.death_remarks diff --git a/ehr/src/org/labkey/ehr/EHRUpgradeCode.java b/ehr/src/org/labkey/ehr/EHRUpgradeCode.java index 52b3b172c..e59336ace 100644 --- a/ehr/src/org/labkey/ehr/EHRUpgradeCode.java +++ b/ehr/src/org/labkey/ehr/EHRUpgradeCode.java @@ -19,6 +19,7 @@ import org.labkey.api.data.TableInfo; import org.labkey.api.data.UpgradeCode; import org.labkey.api.module.ModuleContext; +import org.labkey.api.module.ModuleLoader; import java.sql.Date; import java.sql.PreparedStatement; @@ -34,34 +35,37 @@ public class EHRUpgradeCode implements UpgradeCode @SuppressWarnings({"UnusedDeclaration"}) public void populateCalendar(final ModuleContext moduleContext) throws SQLException { - GregorianCalendar cal = new GregorianCalendar(1950, Calendar.JANUARY, 1, 0, 0, 0); - cal.set(Calendar.MILLISECOND, 0); + if (ModuleLoader.getInstance().shouldInsertData()) + { + GregorianCalendar cal = new GregorianCalendar(1950, Calendar.JANUARY, 1, 0, 0, 0); + cal.set(Calendar.MILLISECOND, 0); - // Insert rows from January 1, 1950 to December 31, 2029 - TableInfo calendar = EHRSchema.getInstance().getEHRLookupsSchema().getTable("Calendar"); + // Insert rows from January 1, 1950 to December 31, 2029 + TableInfo calendar = EHRSchema.getInstance().getEHRLookupsSchema().getTable("Calendar"); - try (DbScope.Transaction transaction = calendar.getSchema().getScope().ensureTransaction(); - PreparedStatement stmt = transaction.getConnection().prepareStatement( - "INSERT INTO ehr_lookups.calendar\n" + - "\t(TargetDateTime, TargetDate, Year, Month, Day, DayAfter)\n" + - "\tVALUES (?, ?, ?, ?, ?, ?)")) - { - while (cal.get(Calendar.YEAR) < 2030) + try (DbScope.Transaction transaction = calendar.getSchema().getScope().ensureTransaction(); + PreparedStatement stmt = transaction.getConnection().prepareStatement( + "INSERT INTO ehr_lookups.calendar\n" + + "\t(TargetDateTime, TargetDate, Year, Month, Day, DayAfter)\n" + + "\tVALUES (?, ?, ?, ?, ?, ?)")) { - stmt.setDate(1, new Date(cal.getTimeInMillis())); - stmt.setDate(2, new Date(cal.getTimeInMillis())); - stmt.setInt(3, cal.get(Calendar.YEAR)); - // java.util.Calendar months are 0-based - stmt.setInt(4, cal.get(Calendar.MONTH) + 1); - stmt.setInt(5, cal.get(Calendar.DAY_OF_MONTH)); + while (cal.get(Calendar.YEAR) < 2030) + { + stmt.setDate(1, new Date(cal.getTimeInMillis())); + stmt.setDate(2, new Date(cal.getTimeInMillis())); + stmt.setInt(3, cal.get(Calendar.YEAR)); + // java.util.Calendar months are 0-based + stmt.setInt(4, cal.get(Calendar.MONTH) + 1); + stmt.setInt(5, cal.get(Calendar.DAY_OF_MONTH)); - cal.add(Calendar.DATE, 1); - stmt.setDate(6, new Date(cal.getTimeInMillis())); + cal.add(Calendar.DATE, 1); + stmt.setDate(6, new Date(cal.getTimeInMillis())); - stmt.addBatch(); + stmt.addBatch(); + } + stmt.executeBatch(); + transaction.commit(); } - stmt.executeBatch(); - transaction.commit(); } } } \ No newline at end of file