Tighten birth and conception entry and drop legacy nbri_ehr tables - #20
Open
labkey-martyp wants to merge 16 commits into
Open
Tighten birth and conception entry and drop legacy nbri_ehr tables#20labkey-martyp wants to merge 16 commits into
labkey-martyp wants to merge 16 commits into
Conversation
Conception is the only table left in the nbri_ehr schema — the rest were carried over from the legacy system and nothing reads them, so their queries, lookups and referencing columns go too. On the entry side, birth condition and conception term date are gone, conception date is now required, and the fields the Start with Conception window populates are read-only.
The birth, arrival and death forms each wrote demographics.birth and demographics.death independently, and the death form also hand-set calculated_status. One trigger helper now derives both dates from the saved event records, and status is left to the shared recalc that owns the death/departure precedence. Adds a drift query for reconciling values the old paths left stale.
Adds a test for deleting a death record, which has to hand the status back to the shared recalc rather than assume the animal is alive, and asserts the birth and death dates reach demographics on the arrival, birth and death forms. The birth and deaths sample data disagreed with demographics on nine rows and now matches, leaving only the animals that legitimately have no birth record.
…fb_ehr_birth_conception_cleanup
The code is entered once per animal, on the birth and arrival forms, and stored on demographics so it is available for animal selection and search. A new ehr_lookups.social_code lookup supplies the five codes.
A new project assignment already closes the animal's open one, so the end date is never entered by hand. The arrival and birth key is lowercased to match the actual field name, which it did not match before.
Drops Bulk from the class, form name and label. Also removes the admin-only isAvailable check and the canInsert override, so the form follows the same availability rules as the other data entry forms.
A new group membership already closes the animal's open one through datasetsToCloseOnNewEntry, so the end date is never entered by hand.
labkey-bpatel
approved these changes
Aug 17, 2026
labkey-bpatel
left a comment
There was a problem hiding this comment.
Approving, but please see my comment below plus other Claude medium to low findings.
| */ | ||
| public List<Map<String, Object>> computeDemographicsSync(List<String> ids) | ||
| { | ||
| if (ids == null || ids.isEmpty()) |
There was a problem hiding this comment.
use ids.size() == 0, isEmpty() might not be reliable as per Claude.
An animal can now be put in a group as it arrives or is born rather than through a separate form. The section allows any Id because neither form's animal has a demographics record yet, and the arrival and birth tests cover it.
EHR metadata keys are merged case-sensitively but applied case-insensitively, so performedBy and qcstate replaced the shared performedby and QCState config rather than merging with it. That dropped the performed-by default of the current user, which made Group Assignments fail the submit-final check, along with the QC state initial value and editor config.
A demographics record still in data entry is provisional, so recording a death against it would publish unreviewed arrival or birth data. Admins can override.
Re-checking it on update let a later regression of the demographics state trap a death record that was already in the necropsy workflow.
A NativeArray inherits an isEmpty() that is always true, so the early-return guard skipped every sync.
Hard-coded indices broke whenever the arrival metadata changed which columns the insert view shows. Also reorders the demographics block to species, gender, birth, dam, sire.
The dataset was configured on two layers not to collect performedBy, but the shared dataset trigger rejects any record saved as Completed without one, so the Group Assignments section failed the Arrival and Birth forms. It stays hidden; the value is now seeded from the current user.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale
Tighten what the birth and conception forms accept, and retire the tables the
nbri_ehrschema inherited from the legacy system. The form changes come out of the bulk data entry work: conception term date was never populated, and the birth fields that the Start with Conception window fills could still be edited by hand, which let a birth drift out of sync with the conception it came from. Nothing in the module reads the legacy tables, so they only add noise to the schema browser, the lookup administration page and every future upgrade script.Related Pull Requests
None.
Changes
nbri_ehrschema along with the queries, custom views, lookups and referencing columns that existed only to serve them. Conception is the only table left in the schema.