Open russgray opened 1 year ago
This is not valid json. An extension cannot contain both a value and a sub-extension (spec says "An extension SHALL have either a value (i.e. a value[x] element) or sub-extensions, but not both.")
Should encodeResourceToString
not reject it, in that case? Or even the object builder API? Our concern is that we are able to successfully build resources that cannot be later parsed. If we had a failure during object construction or encoding, it would also mitigate that.
Describe the bug Given a resource with an extension that contains both a value and a subextension, JsonParser can encode it to a string with no error ~(resulting in a valid fhir resource that will be accepted by our fhir store)~ resulting in invalid fhir json that cannot subsequently be parsed.
To Reproduce
The following test will not run to completion. It throws in the
parseResource
call with messageca.uhn.fhir.parser.DataFormatException: HAPI-1811: Extension (URL='http://fhir.patientsknowbest.com/structuredefinition/test') must not have both a value and other contained extensions
This restriction seems unique to the parsing method;
encodeResourceToString
has no such constraint.Expected behavior HAPI should ~be able to parse any valid fhir json, especially where it was the generator of that json initially~ not generate invalid fhir json.
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context Add any other context about the problem here.