Fix: Handle incorrectly labeled 'subtype' field in Contract resource#202
Open
pateldeep04 wants to merge 1 commit intosmart-on-fhir:mainfrom
Open
Fix: Handle incorrectly labeled 'subtype' field in Contract resource#202pateldeep04 wants to merge 1 commit intosmart-on-fhir:mainfrom
pateldeep04 wants to merge 1 commit intosmart-on-fhir:mainfrom
Conversation
mikix
reviewed
Mar 23, 2026
Contributor
There was a problem hiding this comment.
Thanks so much for the PR! But there are a few conceptual issues I have with this fix:
- It shouldn't be done in this repo, actually - this file is a generated file, built by fhir-parser, it should be a PR over there, then once landed, we should generate these model files again in this repo.
- This is an awfully specific fix for a very specific vendor quirk. Do we maybe instead want all field matching to be caseless? Why/why not? It feels odd for a schema compliance library to be so loose, but maybe this is something that could be controlled via the
strictparameter to the FHIR classes. - The original issue is several years old now -- this vendor is still generating broken JSON?
Contributor
There was a problem hiding this comment.
This file presumably didn't mean to get checked in?
| } | ||
|
|
||
| contract = Contract(data) | ||
| assert contract is not None No newline at end of file |
Contributor
There was a problem hiding this comment.
I'd like to see a check that contract.subType == "example"
Comment on lines
+168
to
+169
| if isinstance(value, str): | ||
| jsondict["subType"] = [{"text": value}] |
Contributor
There was a problem hiding this comment.
This seems like more than just case fixing - why mutate the value here? Is this a DSTU2 vs v4 issue being papered over?
This whole block could maybe be simplified as much as:
if jsondict.get("resourceType") == "Contract" and "subtype" in jsondict:
jsondict["subType"] = jsondict.pop("subtype")
mikix
reviewed
Mar 23, 2026
| .format(type(jsondict), type(self))) | ||
|
|
||
| # Fix incorrect field names and structure (ONLY for Contract) | ||
| if isinstance(jsondict, dict) and "subtype" in jsondict: |
Contributor
There was a problem hiding this comment.
You don't need the dict check here, it's already done for you a few lines up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes issue #202 by handling incorrectly labeled "subtype" field
returned by some DSTU2 APIs.
Changes:
All tests pass successfully.