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

Tighten up JSON vs FHIR JSON response formatting #5506

Merged
merged 9 commits into from
Nov 8, 2024

Conversation

mattlong
Copy link
Member

@mattlong mattlong commented Nov 7, 2024

The issue that prompted this further cleanup was that Bot execution responses had been getting the FHIR JSON treatment even when they do not return a FHIR resource.

For backwards compatibility, we still assume a FHIR response if the input to the bot execution was FHIR JSON. For the future, we should consider having a more explicit way to specify the content types.

Fixes #5502

@mattlong mattlong requested a review from a team as a code owner November 7, 2024 18:54
Copy link

vercel bot commented Nov 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medplum-provider ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 8, 2024 8:16pm
medplum-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 8, 2024 8:16pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
medplum-app ⬜️ Ignored (Inspect) Visit Preview Nov 8, 2024 8:16pm
medplum-www ⬜️ Ignored (Inspect) Visit Preview Nov 8, 2024 8:16pm

@@ -534,14 532,16 @@ async function addBotSecrets(
}
}

const MIRRORED_CONTENT_TYPES: string[] = [ContentType.FHIR_JSON, ContentType.TEXT, ContentType.HL7_V2];
Copy link
Member Author

Choose a reason for hiding this comment

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

I would be in favor or removing FHIR_JSON from this list so that we never automatically use FHIR stringify on Bot responses; especially since FHIR stringify wouldn't have even been used up until about a week ago.

Copy link
Member

@ThatOneBro ThatOneBro Nov 7, 2024

Choose a reason for hiding this comment

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

I think this makes sense... Maybe this is a v4 change to avoid breaking people?

What do we think @mattwiller @codyebberson ?

Copy link
Member

Choose a reason for hiding this comment

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

That would cause some Bots' output to change from application/fhir json to application/json, right? I think that should be a reasonable change, since both MIME types are compatible

Copy link
Member

@ThatOneBro ThatOneBro left a comment

Choose a reason for hiding this comment

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

So just for readers from the future, here we stopped mirroring FHIR_JSON content type in the Bot/$execute response by default, since when content type defaults to FHIR_JSON in the client which would trigger that, and subsequently after the change in #5437, would strip out empty arrays which for non-FHIR responses is not expected.

I think we have most of the bases covered now. LGTM

@@ -534,14 532,16 @@ async function addBotSecrets(
}
}

const MIRRORED_CONTENT_TYPES: string[] = [ContentType.TEXT, ContentType.HL7_V2];
Copy link
Member

Choose a reason for hiding this comment

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

👍

// Default to FHIR
return ContentType.FHIR_JSON;
// Default to JSON
return ContentType.JSON;
Copy link
Member

Choose a reason for hiding this comment

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

👍 👍

export type FhirResponse =
| [OperationOutcome]
| [OperationOutcome, Resource]
| [OperationOutcome, Resource, ContentTypeOverride];
Copy link
Member

Choose a reason for hiding this comment

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

For future compatibility, how would you feel about making the 3rd arg into an object such as ExtendedOptions? It seems likely that we will want to add more stuff here over time (http headers, cache control, etc)

Copy link
Member

Choose a reason for hiding this comment

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

I think we were considering refactoring FhirResponse completely for v4 (making it an object)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that makes even more sense.

@mattlong mattlong enabled auto-merge November 8, 2024 20:25
Copy link

sonarqubecloud bot commented Nov 8, 2024

@mattlong mattlong added this pull request to the merge queue Nov 8, 2024
Merged via the queue into main with commit 3fa3ca3 Nov 8, 2024
32 checks passed
@mattlong mattlong deleted the mattlong-json-response-formats branch November 8, 2024 20:45
medplumbot added a commit that referenced this pull request Nov 8, 2024
## What's Changed

* Update deb-s3 upload command (#5494)
* More build-deb action fixes (#5497)
* Added GCP Secret Manager support and configType: gcp (#5462)
* Case-insensitive search on ContactPoint (#5455)
* Centralize token index type determination logic (#5500)
* Gather and validate all resource references at one time (#5496)
* Revert "Gather and validate all resource references at one time (#5496)" (#5504)
* Improve FHIR Datastore docs (#5484)
* Check all references at once (#5508)
* Fix QuestionnaireForm dependency on requestSchema (#5509)
* fix(agent): harden reconnect logic (#5476)
* Tighten up JSON vs FHIR JSON response formatting (#5506)

**Full Changelog**: v3.2.19...v3.2.20
@mattlong mattlong added this to the November 30, 2024 milestone Nov 8, 2024
@reshmakh reshmakh added the fhir-datastore Related to the FHIR datastore, includes API and FHIR operations label Nov 8, 2024
github-merge-queue bot pushed a commit that referenced this pull request Nov 8, 2024
## What's Changed

* Update deb-s3 upload command (#5494)
* More build-deb action fixes (#5497)
* Added GCP Secret Manager support and configType: gcp (#5462)
* Case-insensitive search on ContactPoint (#5455)
* Centralize token index type determination logic (#5500)
* Gather and validate all resource references at one time (#5496)
* Revert "Gather and validate all resource references at one time (#5496)" (#5504)
* Improve FHIR Datastore docs (#5484)
* Check all references at once (#5508)
* Fix QuestionnaireForm dependency on requestSchema (#5509)
* fix(agent): harden reconnect logic (#5476)
* Tighten up JSON vs FHIR JSON response formatting (#5506)

**Full Changelog**: v3.2.19...v3.2.20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fhir-datastore Related to the FHIR datastore, includes API and FHIR operations
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Fix HGAutocompleteBotResponse and related HealthGorilla search results when result is undefined
5 participants