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: 1 addition & 2 deletions ehr/resources/queries/study/Demographics.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ function onInit(event, helper){
});
}

function onUpsert(helper, scriptErrors, row, oldRow){
function onUpsert(helper, scriptErrors, row, oldRow) {
//NOTE: this should be getting set by the birth, death, arrival & departure tables
//ALSO: it should be rare to insert directly into this table. usually this record will be created by inserting into either birth or arrival
if (!row.calculated_status && !helper.isETL()){
row.calculated_status = helper.getJavaHelper().getCalculatedStatusValue(row.Id);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ else if (existing.getProps().isEmpty() && record.getProps().isEmpty())
_cache.put(key, record);
}

private void recacheRecords(Container c, List<String> ids)
public void recacheRecords(Container c, List<String> ids)
{
for (String id : ids)
{
Expand Down
6 changes: 5 additions & 1 deletion ehr/src/org/labkey/ehr/utils/TriggerScriptHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,11 @@ public void createDemographicsRecord(String id, Map<String, Object> props) throw
if (errors.hasErrors())
throw errors;

EHRDemographicsServiceImpl.get().getAnimal(getContainer(), id);
// The normal (re)caching of demographics providers runs before the study module has done its bookkeeping and
// inserted a row into study.participant, which means that calculated lookup values like the animal's current
// age won't resolve until AFTER the call to insertRows() has completed. Thus, refresh the cache for this new
// animal an extra time. See ticket 44283.
EHRDemographicsServiceImpl.get().recacheRecords(getContainer(), Collections.singletonList(id));
}

public void updateDemographicsRecord(List<Map<String, Object>> updatedRows) throws QueryUpdateServiceException, SQLException, BatchValidationException, InvalidKeyException
Expand Down