diff --git a/onprc_ehr/resources/web/onprc_ehr/templates/Epoc_Template.xlsx b/onprc_ehr/resources/web/onprc_ehr/templates/Epoc_Template.xlsx new file mode 100644 index 000000000..88f8dabb7 Binary files /dev/null and b/onprc_ehr/resources/web/onprc_ehr/templates/Epoc_Template.xlsx differ diff --git a/onprc_ehr/resources/web/onprc_ehr/window/ApplyTemplateWindow.js b/onprc_ehr/resources/web/onprc_ehr/window/ApplyTemplateWindow.js index 94c871560..08d7c1abe 100644 --- a/onprc_ehr/resources/web/onprc_ehr/window/ApplyTemplateWindow.js +++ b/onprc_ehr/resources/web/onprc_ehr/window/ApplyTemplateWindow.js @@ -158,7 +158,8 @@ Ext4.define('ONPRC_EHR.window.ApplyTemplateWindow', { Ext4.Msg.alert('Error', 'Must choose a template'); return; } - + var obj ={} + this.animalId = obj.Id; this.loadTemplate(templateId); }, @@ -225,16 +226,59 @@ Ext4.define('ONPRC_EHR.window.ApplyTemplateWindow', { offsetDate.setHours(8); date = offsetDate; + } + if (data.duration > 0) { + var enddate = null; + //this is specifically to handle hydro, when administered ~noon + if (new String(data.duration).match(/H$/)) { + var duration = new String(data.duration); + duration = duration.replace('H', ''); + duration = Number(duration); + duration += encountersRec.get('date').getHours(); + duration = Math.floor(duration / 24); + + enddate = date; + endate = Ext4.Date.clearTime(enddate); + enddate = Ext4.Date.add(enddate, Ext4.Date.DAY, duration); + } + else { + + enddate = offsetDate + enddate = Ext4.Date.add(enddate, Ext4.Date.DAY, data.duration); + enddate.setHours(23); + enddate = enddate; + enddate.setMinutes(59); + enddate = enddate; + + + } } - var obj2 = {}; - obj2 = { - date: date + else + { + + var sdate= Ext4.Date.clone(new Date()); + var soffsetDate = Ext4.Date.add(sdate, Ext4.Date.DAY, data.offset); + var soffsetDate = Ext4.Date.clearTime(soffsetDate); + enddate = soffsetDate; + enddate.setHours(23); + enddate = enddate; + enddate.setMinutes(59); + enddate = enddate; + + } + + var obj2 = {}; + obj2 = { + date: date, + enddate: enddate + }; var newData = Ext4.apply({}, data); - newData = Ext4.apply(newData, obj); - newData = Ext4.apply(newData, obj2); + newData = Ext4.apply(newData, obj); //Adds monkey id + + newData = Ext4.apply(newData, obj2); // add new computed dates toAdd[store.storeId].push(newData); }, this); @@ -261,6 +305,7 @@ Ext4.define('ONPRC_EHR.window.ApplyTemplateWindow', { } }, + getInitialRecordValues: function(){ var ret = []; var date = this.down('#dateField').getValue(); @@ -271,6 +316,7 @@ Ext4.define('ONPRC_EHR.window.ApplyTemplateWindow', { if (this.down('#subjectIds')){ var subjectArray = LDK.Utils.splitIds(this.down('#subjectIds').getValue(),true); Ext4.Array.each(subjectArray, function(subj){ + this.animalId = subj; ret.push(Ext4.apply({ Id: subj }, obj)); @@ -312,6 +358,8 @@ Ext4.define('ONPRC_EHR.window.ApplyTemplateWindow', { return; } + + this.hide(); Ext4.Msg.wait("Loading Template..."); @@ -526,7 +574,7 @@ EHR.DataEntryUtils.registerGridButton('TEMPLATEREV', function(config){ var grid = btn.up('gridpanel'); var menu = this.up('menu').items.get('templatesMenu'); - Ext4.create('EHR.window.ApplyTemplateWindow', { + Ext4.create('ONPRC_EHR.window.ApplyTemplateWindow', { targetGrid: grid, formType: grid.formConfig.name, idSelectionMode: menu.idSelectionMode || 'multi' diff --git a/onprc_ehr/resources/web/onprc_ehr/window/EpocImportWindow.js b/onprc_ehr/resources/web/onprc_ehr/window/EpocImportWindow.js index 7fe59916a..816d39940 100644 --- a/onprc_ehr/resources/web/onprc_ehr/window/EpocImportWindow.js +++ b/onprc_ehr/resources/web/onprc_ehr/window/EpocImportWindow.js @@ -19,7 +19,15 @@ Ext4.define('ONPRC_EHR.window.EpocImportWindow', { items: [{ html: 'This helper allows you to bulk import EPOC data, exported as an excel file from the Epoc software.', style: 'padding-bottom: 10px;' - },{ + },{ + xtype: 'ldk-linkbutton', + text: '[Download Epoc Template]', + scope: this, + style: 'margin-bottom: 10px;', + handler: function(){ + window.location = LABKEY.contextPath + '/onprc_ehr/templates/Epoc_Template.xlsx' + } + },{ xtype: 'textarea', itemId: 'textField', height: 300, diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/TreatmentsFormType.java b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/TreatmentsFormType.java index 0846869e7..219d2f560 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/TreatmentsFormType.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/TreatmentsFormType.java @@ -44,6 +44,9 @@ public TreatmentsFormType(DataEntryFormContext ctx, Module owner) { super(ctx, owner, NAME, LABEL, "Clinical", Arrays.asList( new TaskFormSection(), + //Added 2-19-2016 Blasa + // new NonStoreFormSection("Treatment Template Helper", "Treatment Template Helper", "onprc_AddScheduledTreatmentPanel", Arrays.asList(ClientDependency.supplierFromPath("/onprc_ehr/panel/AddScheduledTreatmentPanel.js"))), + new AnimalDetailsFormSection(), new DrugAdministrationFormSection(ClientDependency.supplierFromPath("onprc_ehr/window/ONPRC_AddScheduledTreatmentWindow.js")), new TreatmentOrdersFormSection() diff --git a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java index c98d1d5db..6a5db6cec 100644 --- a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java +++ b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java @@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.awaitility.Awaitility; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -56,6 +57,7 @@ import java.io.IOException; import java.net.URI; +import java.time.Duration; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Arrays; @@ -1324,8 +1326,10 @@ public void bloodRequestTest() throws IOException, CommandException waitAndClickAndWait(Locator.linkWithText("ASB Services Request")); addBloodDrawRequest(animalId, now, "795644", "Heparin", 12); - checker().withScreenshot("Blood request").verifyTrue("Expected error is not present", isAnyTextPresent( - "Row 1, # of Tubes: ERROR: The quantity requested, 12.0ml exceeds the available blood volume, 10.0ml for AnimalId: 12345")); + Awaitility.await().atMost(Duration.ofSeconds(30)).untilAsserted(() -> { + Assert.assertTrue("Expected error is not present", isAnyTextPresent( + "Row 1, # of Tubes: ERROR: The quantity requested, 12.0ml exceeds the available blood volume, 10.0ml for AnimalId: 12345")); + }); //Updating the total volume below the available blood volume. updateTotalVolume(8);