Skip to content

Move conception records to a study dataset and report the elapsed days - #42

Open
labkey-martyp wants to merge 4 commits into
release26.7-SNAPSHOTfrom
26.7_fb_conception_dataset
Open

Move conception records to a study dataset and report the elapsed days#42
labkey-martyp wants to merge 4 commits into
release26.7-SNAPSHOTfrom
26.7_fb_conception_dataset

Conversation

@labkey-martyp

Copy link
Copy Markdown
Contributor

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

  • Conception records moved to a study dataset filed against the dam, with the conception date as the record date; the old table is dropped without migrating its rows.
  • Data entry, the animal snapshot, the dam report, and the birth and pregnancy outcome triggers all read the dataset instead of the schema table.
  • The hand-maintained QC state metadata and the dam-announcing trigger are gone, replaced by what the dataset provides natively.
  • Conception Id uniqueness is now enforced by the trigger script rather than a database constraint.
  • Each conception carries a calculated count of days elapsed since the conception date, shown on the dam report and beside the conception Id in the animal snapshot's Pregnant field.
  • The snapshot reads that count from the cached demographics record, so it can trail the report by up to a day.

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.
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.

1 participant