Skip to content

Commit e11bed8

Browse files
Performedby ETL fixes (#605)
* Birth and death source queries * performedby ETL transforms
1 parent eaf96ce commit e11bed8

7 files changed

Lines changed: 17 additions & 5 deletions

File tree

nirc_ehr/resources/etls/ProjectAndAssignment.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
bulkLoad="true" batchSize="5000" targetOption="truncate">
2121
<columnTransforms>
2222
<column source="assignmentDate" target="date"/>
23+
<column source="performedby" target="performedby" transformClass="org.labkey.nirc_ehr.columnTransform.NIRCUserCreateTransform"/>
2324
</columnTransforms>
2425
</destination>
2526
</transform>

nirc_ehr/resources/etls/birth.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</alternateKeys>
1414
<columnTransforms>
1515
<column source="birthDate" target="date"/>
16+
<column source="performedby" target="performedby" transformClass="org.labkey.nirc_ehr.columnTransform.NIRCUserCreateTransform"/>
1617
</columnTransforms>
1718
</destination>
1819
</transform>

nirc_ehr/resources/etls/deaths.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</alternateKeys>
1414
<columnTransforms>
1515
<column source="deathDate" target="date"/>
16+
<column source="performedby" target="performedby" transformClass="org.labkey.nirc_ehr.columnTransform.NIRCUserCreateTransform"/>
1617
</columnTransforms>
1718
</destination>
1819
</transform>

nirc_ehr/resources/etls/demographics.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</alternateKeys>
1414
<columnTransforms>
1515
<column source="BIRTH_DATE" target="date"/>
16+
<column source="performedby" target="performedby" transformClass="org.labkey.nirc_ehr.columnTransform.NIRCUserCreateTransform"/>
1617
</columnTransforms>
1718
</destination>
1819
</transform>

nirc_ehr/resources/queries/dbo/q_births.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
SELECT anm.ANIMAL_ID_NUMBER AS participantId,
22
anm.BIRTH_DATE AS birthDate,
3+
(CASE
4+
WHEN (ae.STAFF_ID.STAFF_FIRST_NAME IS NULL OR ae.STAFF_ID.STAFF_LAST_NAME IS NULL) THEN 'unknown'
5+
ELSE (trim(ae.STAFF_ID.STAFF_FIRST_NAME)
6+
|| '|' || trim(ae.STAFF_ID.STAFF_LAST_NAME)) END) AS performedby,
37
-- audit timestamp for modifications or animal event received for created
48
COALESCE(MAX(CAST(adt.CHANGE_DATETIME AS TIMESTAMP)), ae.CREATED_DATETIME) AS modified
59
FROM Animal anm
@@ -12,4 +16,6 @@ AND anm.ANIMAL_ID_NUMBER LIKE 'A%' -- Animal born in centers are pre-appended wi
1216
AND alt.DESCRIPTION IS NOT NULL
1317
GROUP BY anm.ANIMAL_ID_NUMBER,
1418
anm.BIRTH_DATE,
19+
ae.STAFF_ID.STAFF_FIRST_NAME,
20+
ae.STAFF_ID.STAFF_LAST_NAME,
1521
ae.CREATED_DATETIME

nirc_ehr/resources/queries/dbo/q_deaths.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
SELECT an.ANIMAL_ID_NUMBER AS participantId,
33
an.DEATH_DATE AS deathDate,
44
an.TERMINATION_REASON_ID as reason,
5+
(CASE
6+
WHEN (ae.STAFF_ID.STAFF_FIRST_NAME IS NULL OR ae.STAFF_ID.STAFF_LAST_NAME IS NULL) THEN 'unknown'
7+
ELSE (trim(ae.STAFF_ID.STAFF_FIRST_NAME)
8+
|| '|' || trim(ae.STAFF_ID.STAFF_LAST_NAME)) END) AS performedby,
59
COALESCE(MAX(CAST(adt.CHANGE_DATETIME AS TIMESTAMP)), ae.CREATED_DATETIME) AS modified
610
FROM Animal an
711
LEFT JOIN AUDIT_TRAIL adt ON an.ANIMAL_ID = substring(PRIMARY_KEY_VALUES, length('ANIMAL_ID = '))
@@ -12,4 +16,6 @@ AND an.TERMINATION_REASON_ID != 10 -- Invalid Id
1216
GROUP BY an.ANIMAL_ID_NUMBER,
1317
an.DEATH_DATE,
1418
an.TERMINATION_REASON_ID,
19+
ae.STAFF_ID.STAFF_FIRST_NAME,
20+
ae.STAFF_ID.STAFF_LAST_NAME,
1521
ae.CREATED_DATETIME

nirc_ehr/src/org/labkey/nirc_ehr/table/NIRC_EHRSharedDatasetTrigger.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ private void verifyPerformedBy(TableInfo table, @Nullable Map<String, Object> ne
2626
{
2727
if (newRow != null && newRow.containsKey("performedby") && newRow.get("performedby") == null)
2828
{
29-
if (!newRow.containsKey("QCStateLabel") || newRow.get("QCStateLabel") == null)
30-
{
31-
errors.addFieldError("performedby", "Record in " + table.getTitle() + " cannot be submitted without Performed By if QCStateLabel is not found. Contact your administrator.");
32-
}
33-
else if (newRow.containsKey("QCStateLabel") && newRow.get("QCStateLabel").equals("Completed"))
29+
if (newRow.containsKey("QCStateLabel") && "Completed".equals(newRow.get("QCStateLabel")))
3430
{
3531
errors.addFieldError("performedby", "Performed By must be entered in all records before submitting final. Table: " + table.getTitle());
3632
}

0 commit comments

Comments
 (0)