Move conception records to a study dataset and report the elapsed days - #42
Merged
Merged
Conversation
The dam becomes the participant and the conception date the visit date, so the shared EHR trigger announces the modified dam and the hand-rolled QC state metadata goes away. Existing rows are not migrated, and the unique constraint on the conception Id is now enforced by the trigger script.
Calendar days are differenced rather than instants, so a conception entered today reads zero.
The snapshot's Pregnant field reads the count from the cached demographics record, so it can trail the report by a day until the entry expires.
The 26.002-26.003 script never ran: the module still declared schema version 26.002, so nbri_ehr.Conception survived and no longer matched nbri_ehr.xml. The shared dataset trigger rejects a Completed record with no performedby, which the conception dataset is now subject to, so the test's API inserts have to supply one.
The birth and pregnancy conception lookups had no display column, so the dataset's title column decided what they rendered, and with none set that falls back to the first string column: the dam.
EHR assigns a details URL only to demographics, so the conception dataset had none and every lookup into it rendered as plain text instead of a link.
The module registers NBRI_EHRCustomizer for all schemas and tables, so a dataset already gets it and declaring it here only ran it a second time.
ankurjuneja
approved these changes
Sep 12, 2026
Exempting ETL from the conceptId check left duplicates that make getConceptionDam() throw on a later birth or pregnancy save, now that no unique constraint backs it. conceptionDays goes null once a birth or pregnancy outcome claims the conception, and the animal snapshot counts the days at render time rather than reading a figure the demographics cache can hold for 25 hours.
labkey-martyp
commented
Sep 13, 2026
labkey-martyp
left a comment
Contributor
Author
There was a problem hiding this comment.
No new test failures. Need to reimport study and repopulate conception records.
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
Moves conception records out of the nbri_ehr schema into a study dataset keyed on the dam and the conception date, and adds an elapsed day count so how far along a pregnancy is can be seen wherever a conception appears.
As a dataset the records pick up the EHR framework's participant handling, QC state workflow and audit behaviour, all of which the hard table had been reproducing by hand — a whole trigger script existed only to announce the modified dam, because the table had no Id column to announce her from. It also leaves the nbri_ehr schema with no tables, though its custom queries stay.
Two consequences are worth knowing when reviewing: existing conception rows are not migrated, and the conception Id uniqueness the database used to enforce is now enforced by the trigger script. The upgrade script drops the old table but does not reload the folder, so an existing container needs a study reload before the dataset exists and the conception form and its queries resolve.
Related Pull Requests
None.
Changes