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

Allow datetime values to be treated as strings #3900

Merged
merged 6 commits into from
Jun 11, 2024

Conversation

rogordon01
Copy link
Contributor

@rogordon01 rogordon01 commented Jun 5, 2024

Currently, default Newtonsoft JsonSerialization settings are used when performing Json deserialization. This impacts datetime values, as the default behavior is to convert them into .Net DateTime objects. This causes unwanted formatting issues and leads to loss of TimeZone information on the converted data.

This PR allows end users to instruct Newtonsoft to simply treat dates as strings during deserialization. This allows the datetime information to be preserved as-is. They can then be assured that any filters are applied on the original value, and not a value modified by Newtownsoft.

End users must opt-in to this new behavior by specifying a new Parameter.

Current behavior:
image

When enabled:
image

Description

Describe the changes in this PR.

Related issues

Addresses AB#120779.

Testing

Describe how this change was tested.

FHIR Team Checklist

  • Update the title of the PR to be succinct and less than 65 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
  • Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
  • Tag the PR with Schema Version backward compatible or Schema Version backward incompatible or Schema Version unchanged if this adds or updates Sql script which is/is not backward compatible with the code.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Patch|Skip|Feature|Breaking (reason)

@rogordon01 rogordon01 requested a review from a team as a code owner June 5, 2024 22:27
@rogordon01 rogordon01 added Enhancement Enhancement on existing functionality. Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs labels Jun 5, 2024
@rogordon01 rogordon01 added this to the S142 milestone Jun 5, 2024
@rogordon01 rogordon01 changed the title Allow date time values to be treated as strings during json deserialization Allow datetime values to be treated as strings Jun 5, 2024
Copy link

@ChaChaChaChami ChaChaChaChami left a comment

Choose a reason for hiding this comment

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

Makes sense.

@@ -92,7 +93,7 @@ public async Task GivenCcdaConvertDataRequest_WithADefaultTemplates_CorrectResul
public async Task GivenJsonConvertDataRequest_WithADefaultTemplates_CorrectResultShouldReturn()
{
var convertDataEngine = GetDefaultEngine();
var request = GetJsonRequestWithDefaultTemplates();
var request = GetJsonRequestWithDefaultTemplates(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add param name for values passed as is.

@@ -180,6 +189,7 @@ private static HashSet<string> GetSupportedParams()
ConvertDataProperties.InputDataType,
ConvertDataProperties.TemplateCollectionReference,
ConvertDataProperties.RootTemplate,
ConvertDataProperties.JsonDeserializationTreatDatesAsStrings,
Copy link
Contributor

Choose a reason for hiding this comment

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

By adding it in the supported param list, upon validation of params we are enforcing this parameter is provided in the request, right? Is that intended or can this simply not be provided in the request and default if so. If it is the former, I suppose we will need an api version update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The supported param list contains all of the params that this controller works with. So if a parameter provided by the end user doesn't exist within this list then the user will get an error. It doesn't enforce that these params need to exist, though. The various ReadXXXParameter method seem to do that.

As you've stated, I've opted to allow a default value to be used if one isn't provided. I added a new ReadBoolParameter which will return false if the parameter is not present.

pallar-ms
pallar-ms previously approved these changes Jun 10, 2024
@rogordon01 rogordon01 enabled auto-merge (squash) June 11, 2024 21:35
@rogordon01 rogordon01 merged commit e160b04 into main Jun 11, 2024
47 checks passed
@rogordon01 rogordon01 deleted the personal/rogordon/treatDateTimeAsString branch June 11, 2024 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Enhancement Enhancement on existing functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants