6.6.2.5 CanonicalPeriod
6.6.2.5.1 Purpose¶
A state of an animal or group with a start and an end: a lactation, a dry period, a pregnancy, a withdrawal. Periods are usually computed from resolved events, and recomputed when a resolution changes.
6.6.2.5.2 Questions it answers¶
- Is this cow in lactation, and in which lactation?
- When did a period start and end, and which events bounded it?
- Is a withdrawal period active?
6.6.2.5.3 Fields¶
| Field | Type | Cardinality | Description |
|---|---|---|---|
id |
string (uuid) |
1..1 |
Key. |
period_type |
PeriodType | 1..1 |
|
period |
ObservedPeriod | 1..1 |
|
start_event |
ResolvedEvent | 0..1 |
Optional: some periods start before our data or without a recorded event. Points to the resolved fact, not to one source's evidence. Periods are recomputed when a resolution changes. |
end_event |
ResolvedEvent | 0..1 |
e.g. the DryOffEvent or HerdExitEvent that closed a lactation. |
status |
enum | 1..1 |
Values: open, closed, unknown, cancelled.Open requires explicitly open end; unknown end is not open; cancelled remains in history. |
ordinal_reported |
integer |
0..1 |
Number given by the source, e.g. lactation number. |
ordinal_computed |
integer |
0..1 |
Number computed by us; kept separately because the two can disagree. |
source_producer |
SourceProducerEntity | 1..1 |
Usually a ComputedSourceOrigin when we derive the period from events. |
revision |
RecordRevision | 1..1 |
|
derivation |
CanonicalDerivation | 0..1 |
Required for computed periods; inputs identify exact resolved-event revisions. |
created_at |
datetime |
1..1 |
|
updated_at |
datetime |
1..1 |
|
withdrawal_details |
WithdrawalSpec | 0..1 |
|
raw_metadata |
RawMetadata | 0..1 |
Required for periods reported by a source; computed periods have a derivation (CanonicalPeriod.derivation) instead. See LINEAGE. |
raw_locator |
string |
0..1 |
|
farm |
Farm | 1..1 |
For reported periods, the farm of the feed; for computed periods, the farm of the resolved events they come from. Key of partitioning, row-level access and erasure; see STORAGE. Only for period_type = withdrawal; causing treatment is start_event or a derivation input. |
6.6.2.5.4 Subtypes¶
Discriminator subject: every CanonicalPeriod is exactly one of the subtypes below (disjoint and complete).
AnimalPeriod¶
| Field | Type | Cardinality | Description |
|---|---|---|---|
animal |
Animal | 1..1 |
AnimalGroupPeriod¶
| Field | Type | Cardinality | Description |
|---|---|---|---|
animal_group |
AnimalGroup | 1..1 |
6.6.2.5.5 Relationships¶
References
CanonicalPeriod.period_type→ PeriodType (1..1)CanonicalPeriod.start_event→ ResolvedEvent (0..1)CanonicalPeriod.end_event→ ResolvedEvent (0..1)CanonicalPeriod.source_producer→ SourceProducerEntity (1..1)CanonicalPeriod.derivation→ CanonicalDerivation (0..1)AnimalPeriod.animal→ Animal (1..1)AnimalGroupPeriod.animal_group→ AnimalGroup (1..1)CanonicalPeriod.raw_metadata→ RawMetadata (0..1)CanonicalPeriod.farm→ Farm (1..1)
Uses types
ObservedPeriod, RecordRevision, WithdrawalSpec
Subtypes
- by
subject: AnimalPeriod, AnimalGroupPeriod
6.6.2.5.6 Rules & constraints¶
- A state of a subject with a start and an end.
- Covers every kind of period in the PeriodType catalog (PeriodType), not only lactation.
- A lactation 0 recorded at birth by some software is not a lactation.
- Group membership and ownership already have their own periods (AnimalGroupMembership, Ownership): they are not CanonicalPeriods.