Skip to content

Biocontainment Observations TAC to CAMP export - #1019

Open
RameshRapa wants to merge 3 commits into
release26.3-SNAPSHOTfrom
26.3_fb_tac_camp_bioObs
Open

RameshRapa wants to merge 3 commits into
release26.3-SNAPSHOTfrom
26.3_fb_tac_camp_bioObs

Conversation

@RameshRapa

Copy link
Copy Markdown
Collaborator

This PR has code changes for Biocontainment Observations TAC to CAMP export data implementation.

…tenCO, FoodEnrichmentCO and DehydrationCO so that the ETL merge populates them in TAC_src.BiocontainmentObservations
RETURN;
END;

INSERT INTO dbo.editCommentBuffer (tableName, tid, editComment)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This write to editCommentBuffer broke every write back on Moe for the demo branch. CAMP's update trigger needs the editCommentBuffer row to exist before the update so the insert has to move above it, plus a cleanup for the rows that lose the rowversion check.

END;

INSERT INTO dbo.editCommentBuffer (tableName, tid, editComment)
SELECT 'BiocontainmentObservation', targetTid, 'TAC ETL sync'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CAMP's audit trail can't tell who made the edit in TAC. We should put the TAC user's email or username in there instead of a fixed string, since we are able to retrieve that from the labkey db. editComment would be the only place in CAMP's audit that can show who made the change.

l.NasalDischarge, l.FeedEaten, l.FeedEaten_CO, l.FoodEnrichment,
l.FoodEnrichment_CO, l.Stool, l.FluidIntake, l.Dehydration,
l.Dehydration_CO, l.Comment
FROM TAC_src.BiocontainmentObservations l

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now on approval, or a CAMP row coming back through the import, gets updated in CAMP with the same values and writes audit rows for an edit nobody made. Can we only fan out rows whose values actually differ from CAMP?

FluidIntake = COALESCE(m.FluidIntake, b.FluidIntake),
Dehydration = COALESCE(m.Dehydration, b.Dehydration),
Dehydration_CO = COALESCE(m.Dehydration_CO, b.Dehydration_CO),
Comment = COALESCE(m.Comment, b.Comment)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is the one nullable column, so COALESCE means clearing it in TAC never reaches CAMP, and the import pulls the old one back in TAC. This one should just be a straight assignment instead

-- Log (non-fatal) any not-yet-fanned-out landing rows that didn't match
-- a CAMP row.
IF EXISTS (SELECT 1 FROM TAC_src.BiocontainmentObservations l
WHERE (l.FannedOutDate IS NULL OR l.FannedOutDate < l.Modified)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FannedOutDate in 4 places is set from SQL Server's clock but compared against Labkey's modified, so any skew between two servers can make a later edit look already sent. If we store the modified value we pushed instead of GETDATE() both sides come from the same clock

WHERE (l.FannedOutDate IS NULL OR l.FannedOutDate < l.Modified)
AND NOT EXISTS (SELECT 1 FROM @matched m WHERE m.landingObjectId = l.objectid)
);
RAISERROR('TAC_src.usp_FanOutBiocontainmentObservations: %d row(s) had no matching ObjectId in dbo.BiocontainmentObservation and were skipped', 10, 1, @unmatchedCount) WITH NOWAIT;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity 10 RAISERRORs don't come back through SqlExecutor, so the skipped and conflict counts never show up in the ETL log. Can the proc return counts as a result set and have the task log them?

Comment = COALESCE(m.Comment, b.Comment)
OUTPUT inserted.tid, m.landingTid INTO @updated (targetTid, landingTid)
FROM dbo.BiocontainmentObservation b
INNER JOIN @matched m ON m.targetTid = b.tid AND b.timestamp = m.capturedTimestamp;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the fan out updates every row in one statement, one value CAMP's check constraints reject rolls back the whole batch, and the same row blocks every write back every 10 minutes after that. We should skip rows that would fail constraints and report them in the counts instead of blocking the entire record set

</alternateKeys>
<columnTransforms>
<column source="createdBy" target="createdBy" transformClass="org.labkey.snprc_ehr.columnTransforms.UserTransform"/>
<column source="modifiedBy" target="modifiedBy" transformClass="org.labkey.snprc_ehr.columnTransforms.UserTransform"/>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createdBy and modifiedBy should already be Labkey user IDs. The UserTransforms here create a deactivated @noreply-txbiomed.org style user for every editor. I think we should drop the columnTransforms block here

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.

2 participants