FHIR Chat · FHIR Parser · dotnet

Stream: dotnet

Topic: FHIR Parser


view this post on Zulip Richard Kavanagh (Dec 04 2018 at 21:09):

I recently ran into an issue with the .NET parser which I thought I would mention as I think it may be an issue.

Recently I was using the .NET API to access an API as a means of testing it. The API has a JSON interface which contained the following snippet
pasted image

This is wrong as it should have been
pasted image

The .NET parser did not throw any errors and compensated for the missing "[","]". I am assuming this is unintentional behaviour as technically the JSON is incorrect.

So two questions -
1) The JSON in the first snippet is incorrect?
2) Should the parser silently mask the issue?

view this post on Zulip Ewout Kramer (Dec 04 2018 at 21:13):

Hi RIchard - it's indeed the case that the .NET parser ignores a missing array, treating it as an array with a single element. The new non-POCO parsers in 1.0 will catch it, but the POCO-parser still has the problem. The upcoming 1.1 release will have this fixed. It's related to this issue: https://github.com/ewoutkramer/fhir-net-api/issues/756.

view this post on Zulip Richard Kavanagh (Dec 04 2018 at 21:17):

Thanks @Ewout Kramer for confirming this. Good to hear it is been looked at for a future release. For now, we have a bit of an issue in that some of our testing was based on .NET and we did not catch the issue. People using non .NET parsers are now facing issues. Looks like we'll need to switch parts of our toolset to Java for now.

view this post on Zulip Ewout Kramer (Dec 04 2018 at 21:18):

Richard - the release will actually be before christmas - don't know if that helps. We could look at a hotfix if that solves your problem.

view this post on Zulip Richard Kavanagh (Dec 04 2018 at 21:31):

Once again thanks @Ewout Kramer If it's that close then we can probably wait for the release. The changes in the API are having a few issues in other places which I am also working with (note the previous FHIRPath question). The issue is with me to fix the code but I'm struggling in places. Guess I'll be busy over Christmas :-)

view this post on Zulip Vadim Peretokin (Dec 04 2018 at 21:54):

Could also throw in json validation on export as well, no?

view this post on Zulip Ewout Kramer (Dec 04 2018 at 22:01):

Yes, you could. In fact - you could invoke all structural (non-profile) validation logic by parsing xml/json through the typed parses, and then reading all of it:

var tpJson = File.ReadAllText(@"testdata.json");
var tree = FhirJsonNode.Parse(tpJson).ToTypedElement(new PocoStructureDefinitionSummaryProvider());
var errors = tree.VisitAndCatch();

view this post on Zulip Ewout Kramer (Dec 04 2018 at 22:03):

http://docs.simplifier.net/fhirnetapi/parsing.html has more details on what's happening here. This is basically the lower-level functionality that the POCO parsers call.

view this post on Zulip Ewout Kramer (Dec 04 2018 at 22:04):

So, on export, you could run this bit on your generated json. Luckily the POCO serializers will generate correct json ;-)


Last updated: Apr 12 2022 at 19:14 UTC