diff --git a/nbri_ehr/resources/queries/nbri_ehr/Conception.js b/nbri_ehr/resources/queries/nbri_ehr/Conception.js
new file mode 100644
index 0000000..72d57b2
--- /dev/null
+++ b/nbri_ehr/resources/queries/nbri_ehr/Conception.js
@@ -0,0 +1 @@
+require("ehr/triggers").initScript(this);
\ No newline at end of file
diff --git a/nbri_ehr/resources/queries/nbri_ehr/Conception.query.xml b/nbri_ehr/resources/queries/nbri_ehr/Conception.query.xml
new file mode 100644
index 0000000..0eb26a8
--- /dev/null
+++ b/nbri_ehr/resources/queries/nbri_ehr/Conception.query.xml
@@ -0,0 +1,39 @@
+
+
+
+
+ Conception Records
+
+
+ true
+
+
+ Conception Id
+ true
+
+
+ Conception Date
+
+
+ Conception Date
+
+
+ Conception Term Date
+
+
+ true
+
+
+
+ Status
+
+ core
+ qcstate
+ rowid
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nbri_ehr/resources/queries/nbri_ehr/ConceptionsByDam.query.xml b/nbri_ehr/resources/queries/nbri_ehr/ConceptionsByDam.query.xml
new file mode 100644
index 0000000..866a7da
--- /dev/null
+++ b/nbri_ehr/resources/queries/nbri_ehr/ConceptionsByDam.query.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+ Conceptions by Dam
+
+
+ Dam
+
+
+ Conception Id
+
+
+ Conception Outcome
+
+
+
+
+
+
diff --git a/nbri_ehr/resources/queries/nbri_ehr/ConceptionsByDam.sql b/nbri_ehr/resources/queries/nbri_ehr/ConceptionsByDam.sql
new file mode 100644
index 0000000..4554f1d
--- /dev/null
+++ b/nbri_ehr/resources/queries/nbri_ehr/ConceptionsByDam.sql
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2026 LabKey Corporation
+ *
+ * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
+ */
+SELECT
+ c.Dam AS Id,
+ c.ConceptId,
+ c.ConceptDate,
+ c.ConceptTermDate,
+ c.Sire,
+ CASE
+ WHEN b.conceptId IS NOT NULL THEN 'Live Birth'
+ WHEN po.conceptId IS NOT NULL THEN COALESCE(po.result, 'Unknown')
+ ELSE 'Unknown'
+ END AS conceptionOutcome,
+ c.Remark,
+ c.QCState AS qcstate
+FROM Conception c
+LEFT JOIN (SELECT DISTINCT b.conceptId FROM study.birth b WHERE b.conceptId IS NOT NULL) b
+ ON b.conceptId = c.ConceptId
+LEFT JOIN (SELECT p.conceptId, MAX(p.result.title) AS result FROM study.pregnancy p WHERE p.conceptId IS NOT NULL GROUP BY p.conceptId) po
+ ON po.conceptId = c.ConceptId
diff --git a/nbri_ehr/resources/queries/study/birth.js b/nbri_ehr/resources/queries/study/birth.js
index aefe06a..e3e5fd0 100644
--- a/nbri_ehr/resources/queries/study/birth.js
+++ b/nbri_ehr/resources/queries/study/birth.js
@@ -30,6 +30,22 @@ EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Even
EHR.Server.Utils.addError(scriptErrors, 'Id', 'Birth record already exists for this Id, update existing record to change birth information', 'ERROR');
}
+ if (!helper.isETL() && row.conceptId) {
+ if (triggerHelper.totalRecords('nbri_ehr', 'Conception', 'ConceptId', row.conceptId) === 0) {
+ EHR.Server.Utils.addError(scriptErrors, 'conceptId', 'This conception Id does not match any conception record', 'WARN');
+ }
+
+ //when updating a record that already carries this conception id, the existing row accounts for one match
+ var conceptIdThreshold = (oldRow && oldRow.conceptId === row.conceptId) ? 1 : 0;
+ if (triggerHelper.totalRecords('study', 'birth', 'conceptId', row.conceptId) > conceptIdThreshold) {
+ EHR.Server.Utils.addError(scriptErrors, 'conceptId', 'This conception Id is already used by another birth record', 'INFO');
+ }
+
+ if (triggerHelper.totalRecords('study', 'pregnancy', 'conceptId', row.conceptId) > 0) {
+ EHR.Server.Utils.addError(scriptErrors, 'conceptId', 'This conception Id is already used by a pregnancy outcome record', 'INFO');
+ }
+ }
+
if (!helper.isETL()) {
if (row.QCStateLabel) {
diff --git a/nbri_ehr/resources/queries/study/birth.query.xml b/nbri_ehr/resources/queries/study/birth.query.xml
index 4084988..8eccc34 100644
--- a/nbri_ehr/resources/queries/study/birth.query.xml
+++ b/nbri_ehr/resources/queries/study/birth.query.xml
@@ -43,6 +43,14 @@
title
+
+ Conception Id
+
+ nbri_ehr
+ Conception
+ ConceptId
+
+
diff --git a/nbri_ehr/resources/queries/study/pregnancy.js b/nbri_ehr/resources/queries/study/pregnancy.js
index 16e8968..ab4dc7b 100644
--- a/nbri_ehr/resources/queries/study/pregnancy.js
+++ b/nbri_ehr/resources/queries/study/pregnancy.js
@@ -4,9 +4,28 @@
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/
require("ehr/triggers").initScript(this);
+EHR.Server.Utils = require("ehr/utils").EHR.Server.Utils;
var triggerHelper = new org.labkey.nbri_ehr.query.NBRI_EHRTriggerHelper(LABKEY.Security.currentUser.id, LABKEY.Security.currentContainer.id);
+EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'study', 'pregnancy', function(helper, scriptErrors, row, oldRow) {
+ if (!helper.isETL() && row.conceptId) {
+ if (triggerHelper.totalRecords('nbri_ehr', 'Conception', 'ConceptId', row.conceptId) === 0) {
+ EHR.Server.Utils.addError(scriptErrors, 'conceptId', 'This conception Id does not match any conception record', 'WARN');
+ }
+
+ //when updating a record that already carries this conception id, the existing row accounts for one match
+ var conceptIdThreshold = (oldRow && oldRow.conceptId === row.conceptId) ? 1 : 0;
+ if (triggerHelper.totalRecords('study', 'pregnancy', 'conceptId', row.conceptId) > conceptIdThreshold) {
+ EHR.Server.Utils.addError(scriptErrors, 'conceptId', 'This conception Id is already used by another pregnancy outcome record', 'INFO');
+ }
+
+ if (triggerHelper.totalRecords('study', 'birth', 'conceptId', row.conceptId) > 0) {
+ EHR.Server.Utils.addError(scriptErrors, 'conceptId', 'This conception Id is already used by a birth record', 'INFO');
+ }
+ }
+});
+
EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.ON_BECOME_PUBLIC, 'study', 'pregnancy', function(scriptErrors, helper, row, oldRow) {
if (!helper.isETL()) {
diff --git a/nbri_ehr/resources/queries/study/pregnancy.query.xml b/nbri_ehr/resources/queries/study/pregnancy.query.xml
index 35663f8..a97139a 100644
--- a/nbri_ehr/resources/queries/study/pregnancy.query.xml
+++ b/nbri_ehr/resources/queries/study/pregnancy.query.xml
@@ -21,6 +21,14 @@
title
+
+ Conception Id
+
+ nbri_ehr
+ Conception
+ ConceptId
+
+
diff --git a/nbri_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml b/nbri_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml
index f8d49b0..55e48ea 100644
--- a/nbri_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml
+++ b/nbri_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml
@@ -221,6 +221,9 @@
varchar
+
+ varchar
+
@@ -1364,6 +1367,9 @@
varchar
http://cpas.fhcrc.org/exp/xml#fileLink
+
+ varchar
+
diff --git a/nbri_ehr/resources/reports/additionalReports.tsv b/nbri_ehr/resources/reports/additionalReports.tsv
index 98acfbe..8eddd91 100644
--- a/nbri_ehr/resources/reports/additionalReports.tsv
+++ b/nbri_ehr/resources/reports/additionalReports.tsv
@@ -49,4 +49,5 @@ behaviorRemarks Behavior query Behavior Remarks true study BehaviorClinRemarks
clinObsBehavior Behavior query Observations true study behaviorObservations date false false qcstate/publicdata This report contains one record for each encounter with each animal, including surergies, exams, procedures, etc.
clinremarks Clinical query Clinical Remarks true study ClinicalClinRemarks date false false qcstate/publicdata This report contains the clinical remarks entered about each animal
physicalExam Clinical query Exam History True study physicalExam date false false qcstate/publicdata This report displays physical exam data for the selected animal
-historicalOther General query Historical True study historicalOther date false false qcstate/publicdata This report displays historical events from legacy systems
\ No newline at end of file
+historicalOther General query Historical True study historicalOther date false false qcstate/publicdata This report displays historical events from legacy systems
+conceptionsByDam Reproductive Management query Conceptions by Dam true nbri_ehr ConceptionsByDam ConceptDate false false qcstate/publicdata This report displays conception records where the selected animal is the dam
\ No newline at end of file
diff --git a/nbri_ehr/resources/schemas/dbscripts/postgresql/nbri_ehr-26.000-26.001.sql b/nbri_ehr/resources/schemas/dbscripts/postgresql/nbri_ehr-26.000-26.001.sql
new file mode 100644
index 0000000..964b91c
--- /dev/null
+++ b/nbri_ehr/resources/schemas/dbscripts/postgresql/nbri_ehr-26.000-26.001.sql
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2026 LabKey Corporation
+ *
+ * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
+ */
+CREATE TABLE nbri_ehr.Conception
+(
+ RowId SERIAL NOT NULL,
+ ConceptId VARCHAR(100),
+ ConceptDate TIMESTAMP,
+ ConceptTermDate TIMESTAMP,
+ Remark TEXT,
+ Dam VARCHAR(100),
+ Sire VARCHAR(100),
+ TaskId ENTITYID,
+ QCState INTEGER,
+ Container entityId NOT NULL,
+ Created TIMESTAMP,
+ CreatedBy USERID,
+ Modified TIMESTAMP,
+ ModifiedBy USERID,
+ CONSTRAINT PK_CONCEPTION PRIMARY KEY (RowId),
+ CONSTRAINT UQ_CONCEPTION_ConceptId UNIQUE (ConceptId),
+ CONSTRAINT FK_CONCEPTION_Container FOREIGN KEY (Container) REFERENCES core.Containers (EntityId)
+);
+CREATE INDEX IX_Nbri_Ehr_Conception_Container ON nbri_ehr.Conception (Container);
diff --git a/nbri_ehr/resources/schemas/nbri_ehr.xml b/nbri_ehr/resources/schemas/nbri_ehr.xml
index e4cf435..6d076c8 100644
--- a/nbri_ehr/resources/schemas/nbri_ehr.xml
+++ b/nbri_ehr/resources/schemas/nbri_ehr.xml
@@ -569,4 +569,29 @@
+
+ Conception
+ DETAILED
+
+
+
+
+ Date
+
+
+ Date
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nbri_ehr/resources/web/nbri_ehr/model/sources/Birth.js b/nbri_ehr/resources/web/nbri_ehr/model/sources/Birth.js
index 3f6c865..7202b23 100644
--- a/nbri_ehr/resources/web/nbri_ehr/model/sources/Birth.js
+++ b/nbri_ehr/resources/web/nbri_ehr/model/sources/Birth.js
@@ -71,6 +71,11 @@ EHR.model.DataModelManager.registerMetadata('Birth', {
},
'Id/demographics/gender': {
allowBlank: false
+ },
+ conceptId: {
+ columnConfig: {
+ width: 150
+ }
}
}
}
diff --git a/nbri_ehr/resources/web/nbri_ehr/model/sources/Conception.js b/nbri_ehr/resources/web/nbri_ehr/model/sources/Conception.js
new file mode 100644
index 0000000..d862181
--- /dev/null
+++ b/nbri_ehr/resources/web/nbri_ehr/model/sources/Conception.js
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2026 LabKey Corporation
+ *
+ * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
+ */
+EHR.model.DataModelManager.registerMetadata('Conception', {
+ allQueries: {
+
+ },
+ byQuery: {
+ 'nbri_ehr.Conception': {
+ RowId: {
+ allowBlank: true,
+ nullable: true,
+ hidden: true
+ },
+ ConceptId: {
+ allowBlank: false,
+ nullable: false,
+ columnConfig: {
+ width: 200
+ },
+ },
+ ConceptDate: {
+ xtype: 'datefield',
+ extFormat: LABKEY.extDefaultDateFormat,
+ columnConfig: {
+ width: 200
+ },
+ },
+ ConceptTermDate: {
+ xtype: 'datefield',
+ extFormat: LABKEY.extDefaultDateFormat,
+ columnConfig: {
+ width: 200
+ },
+ },
+ Dam: {
+ xtype: 'ehr-animalfield',
+ lookups: false,
+ allowBlank: false,
+ nullable: false,
+ columnConfig: {
+ width: 200
+ },
+ },
+ Sire: {
+ xtype: 'ehr-animalfield',
+ lookups: false,
+ columnConfig: {
+ width: 200
+ },
+ },
+ Remark: {
+ height: 75,
+ editorConfig: {
+ resizeDirections: 's'
+ },
+ columnConfig: {
+ width: 300
+ },
+ }
+ },
+
+ }
+});
diff --git a/nbri_ehr/resources/web/nbri_ehr/model/sources/Pregnancy.js b/nbri_ehr/resources/web/nbri_ehr/model/sources/Pregnancy.js
index 72bb07a..c22335d 100644
--- a/nbri_ehr/resources/web/nbri_ehr/model/sources/Pregnancy.js
+++ b/nbri_ehr/resources/web/nbri_ehr/model/sources/Pregnancy.js
@@ -24,6 +24,11 @@ EHR.model.DataModelManager.registerMetadata('Pregnancy', {
result: {
allowBlank: false,
nullable: false,
+ },
+ conceptId: {
+ columnConfig: {
+ width: 150
+ }
}
},
diff --git a/nbri_ehr/src/org/labkey/nbri_ehr/NBRI_EHRModule.java b/nbri_ehr/src/org/labkey/nbri_ehr/NBRI_EHRModule.java
index 4b262ad..5339e54 100644
--- a/nbri_ehr/src/org/labkey/nbri_ehr/NBRI_EHRModule.java
+++ b/nbri_ehr/src/org/labkey/nbri_ehr/NBRI_EHRModule.java
@@ -80,7 +80,7 @@ public String getName()
@Override
public @Nullable Double getSchemaVersion()
{
- return 26.000;
+ return 26.001;
}
@Override
@@ -236,6 +236,7 @@ private void registerDataEntry()
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NBRIChemistryImportFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NBRISerologyImportFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NBRIRearrivalFormType.class, this));
+ EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NBRIConceptionFormType.class, this));
}
@Override
diff --git a/nbri_ehr/src/org/labkey/nbri_ehr/dataentry/form/NBRIConceptionFormType.java b/nbri_ehr/src/org/labkey/nbri_ehr/dataentry/form/NBRIConceptionFormType.java
new file mode 100644
index 0000000..3da8538
--- /dev/null
+++ b/nbri_ehr/src/org/labkey/nbri_ehr/dataentry/form/NBRIConceptionFormType.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2026 LabKey Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.labkey.nbri_ehr.dataentry.form;
+
+import org.labkey.api.ehr.dataentry.DataEntryFormContext;
+
+import org.labkey.api.ehr.dataentry.FormSection;
+import org.labkey.api.module.Module;
+import org.labkey.api.view.template.ClientDependency;
+import org.labkey.nbri_ehr.dataentry.section.NBRIAnimalDetailsFormSection;
+import org.labkey.nbri_ehr.dataentry.section.NBRIConceptionFormSection;
+import org.labkey.nbri_ehr.dataentry.section.NBRITaskFormSection;
+
+import java.util.List;
+
+public class NBRIConceptionFormType extends NBRIBaseTaskFormType
+{
+ public static final String NAME = "Conception";
+ public static final String LABEL = "Conception";
+
+ public NBRIConceptionFormType(DataEntryFormContext ctx, Module owner)
+ {
+ super(ctx, owner, NAME, LABEL, "Colony Management", List.of(
+ new NBRITaskFormSection(),
+ new NBRIAnimalDetailsFormSection(),
+ new NBRIConceptionFormSection(LABEL)
+ ));
+
+ addClientDependency(ClientDependency.supplierFromPath("nbri_ehr/model/sources/Conception.js"));
+
+ for (FormSection s : getFormSections())
+ {
+ s.addConfigSource("Conception");
+ }
+ }
+}
diff --git a/nbri_ehr/src/org/labkey/nbri_ehr/dataentry/section/NBRIConceptionFormSection.java b/nbri_ehr/src/org/labkey/nbri_ehr/dataentry/section/NBRIConceptionFormSection.java
new file mode 100644
index 0000000..f2cac6a
--- /dev/null
+++ b/nbri_ehr/src/org/labkey/nbri_ehr/dataentry/section/NBRIConceptionFormSection.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2026 LabKey Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.labkey.nbri_ehr.dataentry.section;
+
+public class NBRIConceptionFormSection extends BaseFormSection
+{
+ public NBRIConceptionFormSection(String label)
+ {
+ super("nbri_ehr", "conception", label, "ehr-gridpanel", true, false, false);
+ }
+}
diff --git a/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java b/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java
index 93aeb68..c7587ae 100644
--- a/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java
+++ b/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java
@@ -606,11 +606,17 @@ public void testArrivalForm()
}
@Test
- public void testBirthForm()
+ public void testBirthForm() throws IOException, CommandException
{
String bornAnimal = "80801";
+ String conceptId = "TESTCONCEPT1";
LocalDateTime now = LocalDateTime.now();
+ log("Creating conception record");
+ InsertRowsCommand conception = new InsertRowsCommand("nbri_ehr", "Conception");
+ conception.addRow(Map.of("ConceptId", conceptId, "ConceptDate", now.minusDays(160), "Dam", "TEST4551032"));
+ conception.execute(getApiHelper().getConnection(), getContainerPath());
+
gotoEnterData();
waitAndClickAndWait(Locator.linkWithText("Birth"));
lockForm();
@@ -624,6 +630,7 @@ public void testBirthForm()
births.setGridCell(1, "Id/demographics/gender", "female");
births.setGridCell(1, "project", "795644");
births.setGridCell(1, "birthProtocol", "protocol101");
+ births.setGridCell(1, "conceptId", conceptId);
submitForm("Submit Final", "Finalize");
goToSchemaBrowser();
@@ -633,11 +640,94 @@ public void testBirthForm()
Assert.assertEquals("Invalid Birth record", Arrays.asList("C3"), table.getRowDataAsText(0, "cage"));
Assert.assertEquals("Invalid Birth record", Arrays.asList("795644"), table.getRowDataAsText(0, "project"));
Assert.assertEquals("Invalid Birth record", Arrays.asList("protocol101"), table.getRowDataAsText(0, "birthProtocol"));
+ Assert.assertEquals("Invalid Birth record", Arrays.asList(conceptId), table.getRowDataAsText(0, "conceptId"));
verifyRowCreated("study", "assignment", bornAnimal, 1);
verifyRowCreated("study", "protocolAssignment", bornAnimal, 1);
verifyRowCreated("study", "housing", bornAnimal, 1);
verifyRowCreated("study", "demographics", bornAnimal, 1);
+
+ log("Verifying conception outcome in ConceptionsByDam");
+ goToSchemaBrowser();
+ DataRegionTable report = viewQueryData("nbri_ehr", "ConceptionsByDam");
+ report.setFilter("ConceptId", "Equals", conceptId);
+ Assert.assertEquals("Invalid ConceptionsByDam row", Arrays.asList("Live Birth"), report.getRowDataAsText(0, "conceptionOutcome"));
+ }
+
+ @Test
+ public void testPregnancyForm() throws IOException, CommandException
+ {
+ String animalId = "TEST4551032";
+ String conceptId = "TESTCONCEPT2";
+ LocalDateTime now = LocalDateTime.now();
+
+ log("Creating conception record");
+ InsertRowsCommand conception = new InsertRowsCommand("nbri_ehr", "Conception");
+ conception.addRow(Map.of("ConceptId", conceptId, "ConceptDate", now.minusDays(90), "Dam", animalId));
+ conception.execute(getApiHelper().getConnection(), getContainerPath());
+
+ gotoEnterData();
+ waitAndClickAndWait(Locator.linkWithText("Pregnancy Outcomes"));
+ lockForm();
+
+ Ext4GridRef outcomes = _helper.getExt4GridForFormSection("Pregnancy Outcomes");
+ _helper.addRecordToGrid(outcomes);
+ outcomes.setGridCellJS(1, "date", now.minusDays(1).format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT_STRING)));
+ outcomes.setGridCell(1, "Id", animalId);
+ outcomes.setGridCell(1, "result", "Stillborn");
+ outcomes.setGridCell(1, "conceptId", conceptId);
+ submitForm("Submit Final", "Finalize");
+
+ goToSchemaBrowser();
+ DataRegionTable table = viewQueryData("study", "pregnancy");
+ table.setFilter("Id", "Equals", animalId);
+ Assert.assertEquals("Invalid Pregnancy Outcome record", Arrays.asList(animalId), table.getRowDataAsText(0, "Id"));
+ Assert.assertEquals("Invalid Pregnancy Outcome record", Arrays.asList("Stillborn"), table.getRowDataAsText(0, "result"));
+ Assert.assertEquals("Invalid Pregnancy Outcome record", Arrays.asList(conceptId), table.getRowDataAsText(0, "conceptId"));
+
+ log("Verifying conception outcome in ConceptionsByDam");
+ goToSchemaBrowser();
+ DataRegionTable report = viewQueryData("nbri_ehr", "ConceptionsByDam");
+ report.setFilter("ConceptId", "Equals", conceptId);
+ Assert.assertEquals("Invalid ConceptionsByDam row", Arrays.asList(animalId), report.getRowDataAsText(0, "Id"));
+ Assert.assertEquals("Invalid ConceptionsByDam row", Arrays.asList("Stillborn"), report.getRowDataAsText(0, "conceptionOutcome"));
+ }
+
+ @Test
+ public void testConceptionForm()
+ {
+ String damId = "TEST4551032";
+ String sireId = "44444";
+ String conceptId = "TESTCONCEPT3";
+ LocalDateTime now = LocalDateTime.now();
+
+ gotoEnterData();
+ waitAndClickAndWait(Locator.linkWithText("Conception"));
+ lockForm();
+
+ Ext4GridRef conceptions = _helper.getExt4GridForFormSection("Conception");
+ _helper.addRecordToGrid(conceptions);
+ conceptions.setGridCell(1, "ConceptId", conceptId);
+ conceptions.setGridCellJS(1, "ConceptDate", now.minusDays(30).format(_dateFormat));
+ conceptions.setGridCellJS(1, "ConceptTermDate", now.plusDays(135).format(_dateFormat));
+ conceptions.setGridCell(1, "Dam", damId);
+ conceptions.setGridCell(1, "Sire", sireId);
+ conceptions.setGridCell(1, "Remark", "Conception entry test");
+ submitForm("Submit Final", "Finalize");
+
+ goToSchemaBrowser();
+ DataRegionTable table = viewQueryData("nbri_ehr", "Conception");
+ table.setFilter("ConceptId", "Equals", conceptId);
+ Assert.assertEquals("Invalid Conception record", Arrays.asList(damId), table.getRowDataAsText(0, "Dam"));
+ Assert.assertEquals("Invalid Conception record", Arrays.asList(sireId), table.getRowDataAsText(0, "Sire"));
+ Assert.assertEquals("Invalid Conception record", Arrays.asList("Conception entry test"), table.getRowDataAsText(0, "Remark"));
+
+ log("Verifying unmatched conception appears as Unknown in ConceptionsByDam");
+ goToSchemaBrowser();
+ DataRegionTable report = viewQueryData("nbri_ehr", "ConceptionsByDam");
+ report.setFilter("ConceptId", "Equals", conceptId);
+ Assert.assertEquals("Invalid ConceptionsByDam row", Arrays.asList(damId), report.getRowDataAsText(0, "Id"));
+ Assert.assertEquals("Invalid ConceptionsByDam row", Arrays.asList("Unknown"), report.getRowDataAsText(0, "conceptionOutcome"));
}
@Test