Skip to content

Conversation

@labkey-jeckels
Copy link
Contributor

Rationale

The EHR makes heavy use of queries to calculate values like current animal age and weight via SQL queries wired up as lookups through the Id field. Those lookups only resolve correctly when the study module has already inserted a row into study.participant for the new animal/participant, so we shouldn't trust calculated demographic info until the study module has done its bookkeeping.

Changes

  • When we know we're inserting a new demographics record, likely the first time we've seen an animal, refresh the demographics call an extra time.

@bbimber
Copy link
Collaborator

bbimber commented Nov 16, 2021

@labkey-jeckels so this is being a little picky, but given that caching can be a fairly expensive process, could the trigger force that to happen during another point of the trigger life-cycle, like complete()? Does study.participant have triggers of its own?

@labkey-jeckels
Copy link
Contributor Author

Thanks for the review, Ben.

The current recaching is already happening in the complete() trigger script code, but the order of operations is such that the study bookkeeping happens after that, unfortunately.

I settled on this approach because it only does the extra cache clear on a brand new demographics record (not for updates of an existing demographics row), and because it queues the reload to happen asynchronously. I don't love it, but I couldn't find anything that wasn't a giant hack. I'll give it another look tomorrow morning with a fresh set of eyes though.

@labkey-jeckels
Copy link
Contributor Author

And I should add that the study code is doing a direct INSERT statement against the DB to create the record - see VisitManager.updateParticipants() if you're curious, so it's pretty far removed from supporting its own trigger.

@labkey-jeckels
Copy link
Contributor Author

See my followup commit - I found a reasonable way to avoid firing the normal cache clearing when inserting the new demographics row, which means that we avoid the extra reload

@labkey-jeckels labkey-jeckels merged commit 578b633 into release21.7-SNAPSHOT Nov 17, 2021
@labkey-jeckels labkey-jeckels deleted the 21.7_fb_44283_newAnimalCalculatedDemographicsValues branch November 17, 2021 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants