Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ehr/resources/queries/study/demographicsAge.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ ROUND(CONVERT(age_in_months(d.birth, COALESCE(d.lastDayAtCenter, now())), DOUBLE

ROUND(CONVERT(age_in_months(d.birth, COALESCE(d.lastDayAtCenter, now())), DOUBLE) / 12, 1) AS ageInYears,

TIMESTAMPDIFF('SQL_TSI_DAY', d.birth, COALESCE(d.lastDayAtCenter, now())) as ageInDays,
age_in_days(d.birth, COALESCE(d.lastDayAtCenter, now())) as ageInDays,

case
when (age_in_months(d.birth, COALESCE(d.lastDayAtCenter, now()))) < 1
then (CONVERT(CONVERT(TIMESTAMPDIFF('SQL_TSI_DAY', d.birth, COALESCE(d.lastDayAtCenter, now())), float), VARCHAR) || ' days')
then (CONVERT(CONVERT(age_in_days(d.birth, COALESCE(d.lastDayAtCenter, now())), float), VARCHAR) || ' days')
when (age_in_months(d.birth, COALESCE(d.lastDayAtCenter, now()))) < 12
then (CONVERT(CONVERT(ROUND(age_in_months(d.birth, COALESCE(d.lastDayAtCenter, now())), 1), float), VARCHAR) || ' months')
else
(CONVERT(CONVERT(FLOOR(age_in_months(d.birth, COALESCE(d.lastDayAtCenter, now())) / 12), SQL_INTEGER), VARCHAR) || '.' || CONVERT(MOD(CONVERT(ROUND(age_in_months(d.birth, COALESCE(d.death, now())) / 12.0 * 10.0, 0), SQL_INTEGER), 10), VARCHAR) || ' years')
(CONVERT(CONVERT(FLOOR(age_in_months(d.birth, COALESCE(d.lastDayAtCenter, now())) / 12), SQL_INTEGER), VARCHAR) || '.' || CONVERT(MOD(CONVERT(ROUND(age_in_months(d.birth, COALESCE(d.lastDayAtCenter, now())) / 12.0 * 10.0, 0), SQL_INTEGER), 10), VARCHAR) || ' years')
end as ageFriendly

FROM study.Demographics d
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
-- Dropping ix_ehr_lookups_request_priority_container [container] because it overlaps with uq_request_priority [container, priority]
DROP INDEX ehr_lookups.ix_ehr_lookups_request_priority_container;
-- Dropping ix_ehr_lookups_usda_levels_container [container] because it overlaps with uq_usda_levels [container, usda_level]
DROP INDEX ehr_lookups.ix_ehr_lookups_usda_levels_container;
-- Dropping ix_rooms_container [container] because it overlaps with uq_rooms [container, room]
DROP INDEX ehr_lookups.ix_rooms_container;
-- Dropping ix_ehr_lookups_cage_positions_container [container] because it overlaps with uq_cage_positions [container, cage]
DROP INDEX ehr_lookups.ix_ehr_lookups_cage_positions_container;
-- Dropping ix_ehr_lookups_blood_tube_volumes_container [container] because it overlaps with uq_blood_tube_volumes [container, volume]
DROP INDEX ehr_lookups.ix_ehr_lookups_blood_tube_volumes_container;
-- Dropping ix_ehr_lookups_areas_container [container] because it overlaps with uq_areas [container, area]
DROP INDEX ehr_lookups.ix_ehr_lookups_areas_container;
-- Dropping ix_ehr_lookups_source_container [container] because it overlaps with uq_source [container, code]
DROP INDEX ehr_lookups.ix_ehr_lookups_source_container;
-- Dropping ix_ehr_lookups_flag_categories_container [container] because it overlaps with uq_flag_categories [container, category]
DROP INDEX ehr_lookups.ix_ehr_lookups_flag_categories_container;
-- Dropping ix_ehr_lookups_routes_container [container] because it overlaps with uq_routes [container, route]
DROP INDEX ehr_lookups.ix_ehr_lookups_routes_container;
-- Dropping ix_ehr_lookups_cage_container [container] because it overlaps with uq_cage [container, location]
DROP INDEX ehr_lookups.ix_ehr_lookups_cage_container;
-- Dropping ix_ehr_lookups_blood_draw_services_container [container] because it overlaps with uq_blood_draw_services [container, service]
DROP INDEX ehr_lookups.ix_ehr_lookups_blood_draw_services_container;
-- Dropping ix_ehr_lookups_clinpath_tests_container [container] because it overlaps with uq_clinpath_tests [container, testname]
DROP INDEX ehr_lookups.ix_ehr_lookups_clinpath_tests_container;
-- Dropping ix_ehr_lookups_species_codes_container [container] because it overlaps with uq_species_codes [container, code]
DROP INDEX ehr_lookups.ix_ehr_lookups_species_codes_container;
-- Dropping ix_ehr_lookups_labwork_types_container [container] because it overlaps with uq_labwork_types [container, type]
DROP INDEX ehr_lookups.ix_ehr_lookups_labwork_types_container;
-- Dropping ix_ehr_lookups_death_remarks_container [container] because it overlaps with uq_death_remarks [container, title]
DROP INDEX ehr_lookups.ix_ehr_lookups_death_remarks_container;
-- Dropping ix_ehr_lookups_gender_codes_container [container] because it overlaps with uq_gender_codes [container, code]
DROP INDEX ehr_lookups.ix_ehr_lookups_gender_codes_container;
-- Dropping ix_buildings_container [container] because it overlaps with uq_buildings [container, name]
DROP INDEX ehr_lookups.ix_buildings_container;
-- Dropping ix_ehr_lookups_restraint_type_container [container] because it overlaps with uq_restraint_type [container, type]
DROP INDEX ehr_lookups.ix_ehr_lookups_restraint_type_container;
-- Dropping ix_ehr_lookups_conc_units_container [container] because it overlaps with uq_conc_units [container, unit]
DROP INDEX ehr_lookups.ix_ehr_lookups_conc_units_container;
-- Dropping ix_ehr_lookups_weight_ranges_container [container] because it overlaps with uq_weight_ranges [container, species]
DROP INDEX ehr_lookups.ix_ehr_lookups_weight_ranges_container;
-- Dropping ix_ehr_lookups_dosage_units_container [container] because it overlaps with uq_dosage_units [container, unit]
DROP INDEX ehr_lookups.ix_ehr_lookups_dosage_units_container;
-- Dropping ix_ehr_lookups_volume_units_container [container] because it overlaps with uq_volume_units [container, unit]
DROP INDEX ehr_lookups.ix_ehr_lookups_volume_units_container;
-- Dropping ix_ehr_lookups_blood_draw_tube_type_container [container] because it overlaps with uq_blood_draw_tube_type [container, type]
DROP INDEX ehr_lookups.ix_ehr_lookups_blood_draw_tube_type_container;
-- Dropping ix_ehr_lookups_cage_type_container [container] because it overlaps with uq_cage_type [container, cagetype]
DROP INDEX ehr_lookups.ix_ehr_lookups_cage_type_container;
-- Dropping ix_ehr_lookups_amount_units_container [container] because it overlaps with uq_amount_units [container, unit]
DROP INDEX ehr_lookups.ix_ehr_lookups_amount_units_container;
-- Dropping ix_treatment_codes_container [container] because it overlaps with uq_treatment_codes [container, meaning]
DROP INDEX ehr_lookups.ix_treatment_codes_container;
-- Dropping ix_ehr_lookups_calculated_status_codes_container [container] because it overlaps with uq_calculated_status_codes [container, code]
DROP INDEX ehr_lookups.ix_ehr_lookups_calculated_status_codes_container;
-- Dropping ix_ehr_lookups_species_container [container] because it overlaps with uq_species [container, common]
DROP INDEX ehr_lookups.ix_ehr_lookups_species_container;
-- Dropping ix_ehr_lookups_labwork_services_container [container] because it overlaps with uq_labwork_services [container, servicename]
DROP INDEX ehr_lookups.ix_ehr_lookups_labwork_services_container;
-- Dropping ix_ehr_lookups_parentagetypes_container [container] because it overlaps with uq_parentagetypes [container, label]
DROP INDEX ehr_lookups.ix_ehr_lookups_parentagetypes_container;
68 changes: 62 additions & 6 deletions ehr/resources/web/ehr/data/StoreCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Ext4.define('EHR.data.StoreCollection', {
serverStores: null,
hasLoaded: false, //will be set true after initial load
clientDataChangeBuffer: 150,
validationRequestsInFlight: 0,
ignoredClientEvents: {},

constructor: function(){
Expand All @@ -20,7 +21,7 @@ Ext4.define('EHR.data.StoreCollection', {
this.serverStores = Ext4.create('Ext.util.MixedCollection', false, this.getKey);

this.callParent(arguments);
this.addEvents('commitcomplete', 'commitexception', 'validation', 'initialload', 'load', 'clientdatachanged', 'serverdatachanged');
this.addEvents('commitcomplete', 'commitexception', 'beforevalidation', 'validationstart', 'validation', 'validationcomplete', 'initialload', 'load', 'clientdatachanged', 'serverdatachanged');

this.on('clientdatachanged', this.onClientDataChanged, this, {buffer: this.clientDataChangeBuffer});
},
Expand Down Expand Up @@ -218,24 +219,48 @@ Ext4.define('EHR.data.StoreCollection', {
}
else
{
//this really isnt the right event to fire, but it will force a recalulation of buttons on the panel
//this really isn't the right event to fire, but it will force a recalculation of buttons on the panel
this.fireEvent('validation', this);
}
},

validateAll: function(){
if(this.fireEvent('beforevalidation', this)===false)
return;
this.serverStores.each(function(serverStore){
serverStore.validateRecords(serverStore.getRange(), true);
}, this);
},

validateRecords: function(recordMap){
if(this.fireEvent('beforevalidation', this)===false)
return;
for (var serverStoreId in recordMap){
var serverStore = this.serverStores.get(serverStoreId);
serverStore.validateRecords(Ext4.Object.getValues(recordMap[serverStoreId]), true);
}
},

onValidationRequestStart: function(){
this.validationRequestsInFlight++;

if (this.validationRequestsInFlight === 1){
this.fireEvent('validationstart', this);
}
},

onValidationRequestComplete: function(){
if (!this.validationRequestsInFlight){
return;
}

this.validationRequestsInFlight--;

if (this.validationRequestsInFlight === 0){
this.fireEvent('validationcomplete', this);
}
},

serverToClientDataMap: null,

getServerToClientDataMap: function(){
Expand Down Expand Up @@ -472,11 +497,31 @@ Ext4.define('EHR.data.StoreCollection', {
if (EHR.debug)
console.log(commands);

var success = this.getOnCommitSuccess(recordsArr, validateOnly, retainErrors);
var failure = this.getOnCommitFailure(recordsArr, validateOnly);
var cfg = {
url : LABKEY.ActionURL.buildURL('query', 'saveRows', this.containerPath),
method : 'POST',
success: this.getOnCommitSuccess(recordsArr, validateOnly, retainErrors),
failure: this.getOnCommitFailure(recordsArr, validateOnly),
success: function(response, options){
try {
success.call(this, response, options);
}
finally {
if (validateOnly){
this.onValidationRequestComplete();
}
}
},
failure: function(response, options){
try {
failure.call(this, response, options);
}
finally {
if (validateOnly){
this.onValidationRequestComplete();
}
}
},
scope: this,
timeout: 5000000, //a little extreme?
transacted: true,
Expand All @@ -498,9 +543,20 @@ Ext4.define('EHR.data.StoreCollection', {
if (validateOnly){
cfg.jsonData.validateOnly = true;
cfg.jsonData.extraContext.isValidateOnly = true;
this.onValidationRequestStart();
}

var request;
try {
request = LABKEY.Ajax.request(cfg);
}
catch (e){
if (validateOnly){
this.onValidationRequestComplete();
}

var request = LABKEY.Ajax.request(cfg);
throw e;
}

Ext4.Array.forEach(recordsArr, function(command){
Ext4.Array.forEach(command, function(rec){
Expand Down Expand Up @@ -893,4 +949,4 @@ Ext4.define('EHR.data.StoreCollection', {
s.checkForServerErrorChanges();
}, this);
}
});
});
1 change: 1 addition & 0 deletions ehr/resources/web/ehr/panel/DataEntryErrorPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Ext4.define('EHR.panel.DataEntryErrorPanel', {
this.callParent(arguments);

this.mon(this.storeCollection, 'validation', this.updateErrorMessages, this, {buffer: 1000});
this.mon(this.storeCollection, 'validationcomplete', this.updateErrorMessages, this, {buffer: 50});
this.mon(this.storeCollection, 'commitcomplete', this.updateErrorMessages, this, {buffer: 200});
this.mon(this.storeCollection, 'commitexception', this.updateErrorMessages, this, {buffer: 200});
},
Expand Down
94 changes: 94 additions & 0 deletions ehr/resources/web/ehr/panel/DataEntryPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Ext4.define('EHR.panel.DataEntryPanel', {
storeCollection: null,
hideErrorPanel: false,
useSectionBorder: true,
validationInProgress: false,

layout: 'anchor',
border: false,
Expand All @@ -33,7 +34,10 @@ Ext4.define('EHR.panel.DataEntryPanel', {
this.storeCollection.on('initialload', this.onStoreCollectionInitialLoad, this);
this.storeCollection.on('commitcomplete', this.onStoreCollectionCommitComplete, this);
this.storeCollection.on('validation', this.onStoreCollectionValidation, this);
this.storeCollection.on('validationstart', this.onValidationStart, this);
this.storeCollection.on('validationcomplete', this.onValidationComplete, this);
this.storeCollection.on('beforecommit', this.onStoreCollectionBeforeCommit, this);
this.storeCollection.on('beforevalidation', this.onBeforeValidation, this);
this.storeCollection.on('commitexception', this.onStoreCollectionCommitException, this);
//this.storeCollection.on('serverdatachanged', this.onStoreCollectionServerDataChanged, this);

Expand Down Expand Up @@ -83,13 +87,67 @@ Ext4.define('EHR.panel.DataEntryPanel', {
}
},

onBeforeValidation: function(sc){
function processItem(item) {
if(item.disableOn) {
item.setDisabled(true);
if (item.setTooltip)
item.setTooltip('Disabled waiting on validation. Select "More Actions" -> "Re-Validate" if this is not clearing.');
}

if (item.menu) {
item.menu.items.each(function (menuItem) {
processItem(menuItem);
}, this);
}
}

var ehrContext = LABKEY.getModuleContext('ehr');
if (ehrContext && !ehrContext.isSubmitEnabledOnValidation) {
var btns = this.getToolbarItems();
if (btns) {
Ext4.Array.forEach(btns, function (toolbar) {
toolbar.items.each(function (item) {
processItem(item);
}, this);
}, this);
}
}
},

onValidationStart: function(){
// Suppress the indicator during initial form load/background reconciliation.
if (!this.hasStoreCollectionLoaded || !this.storeCollection || !this.storeCollection.hasLoaded){
return;
}

this.validationInProgress = true;
this.setValidationIndicatorVisible(true);
},

onValidationComplete: function(){
this.validationInProgress = false;
this.setValidationIndicatorVisible(false);

var errorPanel = this.getErrorPanel();
if (errorPanel){
errorPanel.updateErrorMessages();
}

this.onStoreCollectionValidation(this.storeCollection);
},

onStoreCollectionValidation: function(sc){
if (!this.hasStoreCollectionLoaded){
return;
}

this.updateDirtyStateMessage();

if (this.storeCollection && this.storeCollection.validationRequestsInFlight > 0){
return;
}

var maxSeverity = sc.getMaxErrorSeverity();

if(EHR.debug && maxSeverity)
Expand Down Expand Up @@ -276,6 +334,19 @@ Ext4.define('EHR.panel.DataEntryPanel', {
},
items: this.getItemConfig(),
dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
itemId: 'validationIndicator',
hidden: true,
border: false,
plain: true,
style: 'background-color: transparent; padding: 12px 0 0 0;',
items: [{
xtype: 'container',
html: '<span><i class="fa fa-spinner fa-pulse"></i> Validating...</span>',
style: 'font: bold 13px tahoma,arial,verdana,sans-serif; line-height: 16px; color: #C33;'
}]
},{
xtype: 'toolbar',
dock: 'bottom',
ui: 'footer',
Expand Down Expand Up @@ -509,6 +580,29 @@ Ext4.define('EHR.panel.DataEntryPanel', {
return this.dirtyStateArea;
},

getErrorPanel: function(){
if (!this.errorPanel || this.errorPanel.isDestroyed){
this.errorPanel = this.down('#errorPanel');
}

return this.errorPanel;
},

getValidationIndicator: function(){
if (!this.validationIndicator || this.validationIndicator.isDestroyed){
this.validationIndicator = this.down('#validationIndicator');
}

return this.validationIndicator;
},

setValidationIndicatorVisible: function(visible){
var indicator = this.getValidationIndicator();
if (indicator){
indicator.setVisible(visible);
}
},

getButtons: function(){
var buttons = [{
xtype: 'container',
Expand Down
2 changes: 2 additions & 0 deletions ehr/src/org/labkey/ehr/EHRManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public class EHRManager

public static final String EXPERIMENTAL_REACT_PARTICIPANT_REPORTS = "ehrReactParticipantReports";

public static final String EXPERIMENTAL_SUBMIT_ENABLED_ON_VALIDATION = "ehrSubmitEnabledDuringValidation";

// Column name constants to reduce hardcoding
private static final class ColumnNames
{
Expand Down
10 changes: 9 additions & 1 deletion ehr/src/org/labkey/ehr/EHRModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public String getName()
@Override
public @Nullable Double getSchemaVersion()
{
return 26.002;
return 26.003;
}

@Override
Expand Down Expand Up @@ -296,6 +296,11 @@ public void moduleStartupComplete(ServletContext servletContext)
"Use React EHR participant history",
"Links on animal Ids will go to the new React participant history.",
false);

OptionalFeatureService.get().addExperimentalFeatureFlag(EHRManager.EXPERIMENTAL_SUBMIT_ENABLED_ON_VALIDATION,
"Enable 'Submit' buttons during validation",
"User can submit form while validation is in progress",
false);
}

@Override
Expand Down Expand Up @@ -337,6 +342,9 @@ public JSONObject getPageContextJson(ContainerUser context)
// Expose the experimental React participant reports flag to client-side JavaScript
ret.put("isReactAnimalHistoryEnabled", AppProps.getInstance().isOptionalFeatureEnabled(EHRManager.EXPERIMENTAL_REACT_PARTICIPANT_REPORTS));

// Expose the experimental 'submit enabled on validation' flag to client-side JavaScript
ret.put("isSubmitEnabledOnValidation", AppProps.getInstance().isOptionalFeatureEnabled(EHRManager.EXPERIMENTAL_SUBMIT_ENABLED_ON_VALIDATION));

if (map.containsKey(EHRManager.EHRStudyContainerPropName) && map.get(EHRManager.EHRStudyContainerPropName) != null)
{
User u = context.getUser();
Expand Down
Loading
Loading