Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fhir): SAV-901: Set published_date on a Lab Request when published via the FHIR API #7244

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rohan-bes
Copy link
Collaborator

@rohan-bes rohan-bes commented Feb 20, 2025

Changes

Previously when a Lab Request is transitioned to Published by an incoming DiagnosticReport we weren't setting the published_date. We should be doing this.

Deploys

  • Deploy to Tamanu Internal

Remember to...

  • ...write or update tests
  • ...add UI screenshots and testing notes to the Linear issue
  • ...add any manual upgrade steps to the Linear issue
  • ...update the config reference, settings reference, or any relevant runbook(s)
  • ...call out additions or changes to config files for the deployment team to take note of

@rohan-bes rohan-bes force-pushed the fix/sav-901-set-published-date-when-publish-from-fhir branch from fc28b8a to 4ff8392 Compare February 20, 2025 05:23
Copy link
Contributor

@NavarroEmilioLuis NavarroEmilioLuis left a comment

Choose a reason for hiding this comment

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

Hmmmm I think there is one thing we need to double check that is probably a blocker sorry! By the way, curious that it kinda does work based on the test 😂

@@ -114,6 +114,9 @@ export class FhirDiagnosticReport extends FhirResource {

if (this.shouldUpdateLabRequestStatus(labRequest, newStatus)) {
labRequest.set({ status: newStatus });
if (newStatus === LAB_REQUEST_STATUSES.PUBLISHED) {
labRequest.set({ publishedDate: new Date() });
Copy link
Contributor

@NavarroEmilioLuis NavarroEmilioLuis Feb 20, 2025

Choose a reason for hiding this comment

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

Hmmmm but publishedDate seems to be a string, so we probably want the getCurrentDateTimeString() thing? Also assuming it's datetime and not just date here Yeah okay it is datetime string by looking at the model heh

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call! I swapped this out and the tests still passed so maybe it would get handled anyway but best to be explicit that it's a string 👍

Copy link
Contributor

@NavarroEmilioLuis NavarroEmilioLuis left a comment

Choose a reason for hiding this comment

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

Nice! Just one more note before you merge, but good to go!

expect(labRequest.status).toBe(LAB_REQUEST_STATUSES.PUBLISHED);
expect(labRequest.publishedDate).toBe(dateFnsTz.format(fakeDate, 'yyyy-MM-dd HH:mm:ss'));
expect((await labRequest.getLatestAttachment()).title).toBe(testAttachment.title);
jest.useRealTimers();
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmmm is this line really evaluated? I don't know when, but I think I recall that logs past the last expect get ignored? Just double check that it's working I think otherwise we could move it after we get the response hey?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The jest.useRealTimers()? Yep it does, it clears mock on Date.now(). Without it the tests don't work.

I did it this way (mocking inside just the one test) because it seems like our setup/teardown code for these tests relies on Date.now() so this was a simple way to work around that.

However it's a good point if the expect fails for some reason then maybe it won't evaluate 🤔 so I'll move it after getting the response to be safe 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay now I'm confused, I removed the line and it seems like the tests work regardless. I was sure I had tested that previously and it was required... 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh well! Let's keep it for good measure? IDK?

Copy link

Android builds 📱

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