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
3 changes: 3 additions & 0 deletions ehr/resources/queries/ehr_lookups/cage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ function onUpsert(helper, scriptErrors, row, oldRow) {
row.location = row.room;
if (row.cage)
row.location += '-' + row.cage;
if (row.location.length > 24) {
console.log("Location is longer than allowed length: ", row.location);
}

//remove whitespace, normalize punctuation and pad digits
if (row.joinToCage){
Expand Down
21 changes: 12 additions & 9 deletions ehr/resources/scripts/ehr/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,21 @@ EHR.Server.Utils = new function(){
console.error('Unable to parse date string: ' + val);
}
}
else if (!isNaN(val)){
// NOTE: i'm not sure if we should really attempt this. this should really never happen,
// and it's probably an error if it does
normalizedVal = new Date(val);
}
else {
if (val['getTime']){
normalizedVal = new Date(val.getTime());
console.log('EHR trigger script is being passed a date with value: ' + val);
if (!isNaN(val)) {
// NOTE: i'm not sure if we should really attempt this. this should really never happen,
// and it's probably an error if it does
normalizedVal = new Date(val);
}
else {
if (!supppressErrors)
console.error('Unknown datatype for date value. Type was: ' + (typeof val) + ' and value was: ' + val);
if (val['getTime']) {
normalizedVal = new Date(val.getTime());
}
else {
if (!supppressErrors)
console.error('Unknown datatype for date value. Type was: ' + (typeof val) + ' and value was: ' + val);
}
}
}

Expand Down
34 changes: 31 additions & 3 deletions ehr/src/org/labkey/ehr/EHRController.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ public ApiResponse execute(DiscardFormForm form, BindException errors)
public static class EHRQueryForm extends QueryForm
{
private boolean _showImport = false;
private boolean _queryUpdateURL = false;

public boolean isShowImport()
{
Expand All @@ -322,6 +323,16 @@ public void setShowImport(boolean showImport)
{
_showImport = showImport;
}

public boolean isQueryUpdateURL()
{
return _queryUpdateURL;
}

public void setQueryUpdateURL(boolean queryUpdateURL)
{
_queryUpdateURL = queryUpdateURL;
}
}

@RequiresPermission(UpdatePermission.class)
Expand Down Expand Up @@ -417,7 +428,24 @@ else if (isReactForm(form.getSchemaName(), form.getQueryName()))
}

DetailsURL updateUrl;
if (EHRServiceImpl.get().isUseFormEditUI(getContainer()) && null != ti.getColumn("taskid"))
if (form.isQueryUpdateURL())
{
// Send to the query controller's basic row-level update form
StringBuilder sb = new StringBuilder("query-updateQueryRow.view?schemaName=");
sb.append(ti.getUserSchema().getName());
sb.append("&queryName=");
sb.append(ti.getName());
for (String pk : pks)
{
sb.append("&");
sb.append(pk);
sb.append("=${");
sb.append(pk);
sb.append("}");
}
updateUrl = DetailsURL.fromString(sb.toString());
}
else if (EHRServiceImpl.get().isUseFormEditUI(getContainer()) && null != ti.getColumn("taskid"))
{
updateUrl = DetailsURL.fromString("/ehr/dataEntryForm.view?taskid=${taskid}&formType=${taskid/formType}");
}
Expand Down Expand Up @@ -1445,8 +1473,8 @@ public ModelAndView getView(EnterDataForm form, BindException errors)
{
if (form.getFormType() == null)
{
errors.reject(ERROR_MSG, "Must provide either the form type");
return null;
errors.reject(ERROR_MSG, "Must provide a form type");
return new SimpleErrorView(errors);
}

_def = DataEntryManager.get().getFormByName(form.getFormType(), getContainer(), getUser());
Expand Down
78 changes: 10 additions & 68 deletions ehr/test/src/org/labkey/test/tests/ehr/AbstractEHRTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ abstract public class AbstractEHRTest extends BaseWebDriverTest implements Advan
protected List<Long> _saveRowsTimes;

protected abstract String getModuleDirectory();
private EHRSetupHelper _setupHelper = new EHRSetupHelper(this, getProjectName(), FOLDER_NAME, getModulePath(), getContainerPath());
protected EHRBillingHelper _billingHelper = new EHRBillingHelper(this, getProjectName(), FOLDER_NAME, getModulePath(), getContainerPath(),BILLING_FOLDER);

//xpath fragment
Expand Down Expand Up @@ -221,7 +220,7 @@ protected void createTestSubjects() throws Exception
{
String[] fields;
Object[][] data;
PostCommand insertCommand;
PostCommand<?> insertCommand;

//insert into demographics
log("Creating test subjects");
Expand Down Expand Up @@ -376,22 +375,26 @@ protected void createProjectAndFolders(String type)
_containerHelper.createSubfolder(getProjectName(), getProjectName(), FOLDER_NAME, type, null);
}

/** Hook for center-specific setup that needs to happen after the containers are created but before the study is imported */
protected void doExtraPreStudyImportSetup()
{

}

@LogMethod
protected void initProject() throws Exception
{
initProject("EHR");
}

@LogMethod
protected void initProject(String type) throws Exception
{
createProjectAndFolders(type);
setFormatStrings();
setEHRModuleProperties();
createUsersandPermissions();//note: we create the users prior to study import, b/c that user is used by TableCustomizers
if(type.equals("TNPRC EHR"))
_setupHelper.loadEHRTableDefinitions();
if(type.equals("ONPRC EHR"))
onprcSetupBeforeStudyUpload(); //this needs to happen before import study() below so that 'Validation Queries' step doesn't fail since the queries depend on setup in this method.

doExtraPreStudyImportSetup();

populateInitialData();
defineQCStates();
Expand All @@ -406,67 +409,6 @@ protected void initProject(String type) throws Exception
primeCaches();
}

private void onprcSetupBeforeStudyUpload()
{
//create onprc_billing_public linked schema
beginAt(getProjectName());
SchemaHelper schemaHelper = new SchemaHelper(this);
schemaHelper.createLinkedSchema(this.getProjectName(), null, "onprc_billing_public", "/" + this.getContainerPath(), "onprc_billing_public", null, null, null);

//create Labfee_NoChargeProjects
beginAt(getProjectName());

ListHelper.ListColumn projectCol= new ListHelper.ListColumn("project", ListHelper.ListColumnType.Integer);
ListHelper.ListColumn startDateCol= new ListHelper.ListColumn("startDate", ListHelper.ListColumnType.DateAndTime);
ListHelper.ListColumn dateDisabledCol= new ListHelper.ListColumn("dateDisabled", ListHelper.ListColumnType.DateAndTime);
ListHelper.ListColumn createdDbCol= new ListHelper.ListColumn("Createdb", ListHelper.ListColumnType.Integer);
ListHelper.ListColumn notesCol= new ListHelper.ListColumn("Notes", ListHelper.ListColumnType.String);
_listHelper.createList(getProjectName(), "Labfee_NoChargeProjects", ListHelper.ListColumnType.Integer, "key", projectCol, startDateCol, dateDisabledCol, createdDbCol, notesCol);

_listHelper.createList(getProjectName(), "GeneticValue", ListHelper.ListColumnType.String, "Id",
new ListHelper.ListColumn("meanKinship", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("zscore", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("genomeUniqueness", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("totalOffspring", ListHelper.ListColumnType.Integer),
new ListHelper.ListColumn("livingOffspring", ListHelper.ListColumnType.Integer),
new ListHelper.ListColumn("assignments", ListHelper.ListColumnType.Integer),
new ListHelper.ListColumn("condition", ListHelper.ListColumnType.String),
new ListHelper.ListColumn("import", ListHelper.ListColumnType.String),
new ListHelper.ListColumn("value", ListHelper.ListColumnType.String),
new ListHelper.ListColumn("rank", ListHelper.ListColumnType.Integer)
);

_listHelper.createList(getProjectName(), "Special_Aliases", ListHelper.ListColumnType.AutoInteger, "Key",
new ListHelper.ListColumn("Category", ListHelper.ListColumnType.String),
new ListHelper.ListColumn("Alias", ListHelper.ListColumnType.String));

// Fake up an external schema connection for "dbo" via a list and a linked schema
_listHelper.createList(getProjectName(), "Rpt_ChargesProjection", ListHelper.ListColumnType.AutoInteger, "RowId",
new ListHelper.ListColumn("ChargeId", ListHelper.ListColumnType.Integer),
new ListHelper.ListColumn("UnitCost", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("year1", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("year2", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("year3", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("year4", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("year5", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("year6", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("year7", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("year8", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("Aprate1", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("Aprate2", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("Aprate3", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("Aprate4", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("Aprate5", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("Aprate6", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("Aprate7", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("Aprate8", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("Aprate9", ListHelper.ListColumnType.Decimal),
new ListHelper.ListColumn("PostedDate", ListHelper.ListColumnType.DateAndTime)
);
schemaHelper.createLinkedSchema(this.getProjectName(), null, "dbo", "/" + this.getContainerPath(), null, "lists", null, null);

}

@LogMethod(quiet = true)
protected void populate(@LoggedParam String tableLabel)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public void testCustomButtons()
recallLocation();
List<String> submenuItems = dr.getHeaderMenuOptions("More Actions");
List<String> expectedSubmenu = Arrays.asList("Jump To History", "Return Distinct Values","Show Record History","Compare Weights","Edit Records");
Assert.assertEquals("More actions menu did not contain expected options",expectedSubmenu, submenuItems);
Assert.assertTrue("More actions menu did not contain expected options. Expected: " + expectedSubmenu + ", but found: " + submenuItems, submenuItems.containsAll(expectedSubmenu));
}

private void testUserAgainstAllStates(@LoggedParam EHRUser user)
Expand Down
60 changes: 0 additions & 60 deletions ehr/test/src/org/labkey/test/tests/ehr/EHRSetupHelper.java

This file was deleted.

Loading