Skip to content

BCDA-10317: Use correct lastUpdated for v3 - #1483

Merged
bhagatparwinder merged 15 commits into
mainfrom
parwinder/BCDA-10317
Sep 4, 2026
Merged

BCDA-10317: Use correct lastUpdated for v3#1483
bhagatparwinder merged 15 commits into
mainfrom
parwinder/BCDA-10317

Conversation

@bhagatparwinder

Copy link
Copy Markdown
Contributor

🎫 Ticket

https://jira.cms.gov/browse/BCDA-10317

🛠 Changes

  • Updated GetBundleLastUpdated() to query BFD and retrieve Bundle.meta.LastUpdated for v3 export jobs, matching v1 and v2 behavior.
  • Added a safeguard fallback in GetBundleLastUpdated().
    • If BFD returns an epoch (1970-01-01), zero, or pre-2000 timestamp (as currently seen with synthetic data in lower environments), it falls back to the job's TransactionTime (time.Now()) and logs a warning.
  • Improved error handling for unknown/unsupported BFD base paths
  • Added unit tests to validate all BFD paths, fallback conditions (epoch, zero, nil bundle), error cases, and unsupported paths.

ℹ️ Context

When processing Bulk FHIR export requests, BCDA sets Job.TransactionTime as the _lastUpdated upper bound for BFD resource queries and returns it to API consumers in the export completion status. API consumers use this transactionTime as the _since lower bound in subsequent exports.

Querying GET /Patient?_id=0 returns Bundle.meta.LastUpdated, which reflects the exact timestamp when the most recent ETL data load completed. Using this value avoids timestamp skew and prevents data gaps between exports.

BFD created a ticket to update the lower environment default to NOW(), the safeguard fallback ensures lower environments and sandbox synthetic data exports continue to function without interruption.

🧪 Validation

Successful unit test execution.

@carlpartridge carlpartridge left a 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.

This was dependent on a BFD change right? Has that been released? Do we want to have a buffer period of time before we deploy this just in the unlikely chance that BFD has to rollback or anything like that?

}

// Safeguard: If BFD lower environments return 1970/epoch or an unpopulated timestamp, fallback to request transaction time. minValidYear guards against epoch (1970) or bogus default dates from mock/lower-environment BFD servers.
const minValidYear = 2000

@carlpartridge carlpartridge Sep 4, 2026

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.

Did BFD come up with this year? Wondering if we should pass it by product as well.

@bhagatparwinder bhagatparwinder Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This piece of code is a safeguard for lower environments if BFD ever starts returning 1970/epoch (again). I can remove this piece of code if preferred or if it is confusing. This was done because:

  • BFD is still making this change for lower environments.
  • In case in the future BFD goes back to its previous behavior, we use TransactionTime as the lastUpdated.

@bhagatparwinder

Copy link
Copy Markdown
Contributor Author

This was dependent on a BFD change right? Has that been released? Do we want to have a buffer period of time before we deploy this just in the unlikely chance that BFD has to rollback or anything like that?

That is what the safeguard code is for. Also, the safeguard only applies to lower environments. Production does give us the correct lastUpdated for v3.

Please see this thread for additional details: https://cmsgov.slack.com/archives/CMT1YS2KY/p1788197054432209

@bhagatparwinder
bhagatparwinder merged commit 97fee93 into main Sep 4, 2026
7 checks passed
@bhagatparwinder
bhagatparwinder deleted the parwinder/BCDA-10317 branch September 4, 2026 21:17
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.

4 participants