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

Polymorphic handling failures #3

Open
janetr1023 opened this issue Jan 6, 2020 · 0 comments
Open

Polymorphic handling failures #3

janetr1023 opened this issue Jan 6, 2020 · 0 comments

Comments

@janetr1023
Copy link

Happy new year :-)

We are using this very helpful utility and have run into issues with polymorphic elements. Please let us know if there is something we are not understanding about how this works or whether this is an issue with the code base.

Regards,
Janet

These examples are for the FHIR v4 MedicationStatement resource, which contains Medication[x] polymorphic element.

The two issues are:

(1) FhirbaseJsonWriter fails to write Medication[x] when it is CodeableConcept.

 The json is:
	{
	  "resourceType": "MedicationStatement",
	  "id": "example005",
	  "status": "entered-in-error",	  
	  "medicationCodeableConcept": {
		"coding": [
		  {
			"system": "http://snomed.info/sct",
			"code": "27658006",
			"display": "Amoxicillin (product)"
		  }
		]
	  },
	  "subject": {
		"reference": "Patient/4d5ed44d-ba1d-41b2-866e-5a9662278ae6",
		"display": "Donald Duck"
	  }
	}
	
   The error is: 
   Newtonsoft.Json.JsonWriterException: Token PropertyName in state Array would result in an invalid JSON object. Path 'medication.codeableconcept.coding'.
       at Newtonsoft.Json.JsonWriter.AutoComplete(JsonToken tokenBeingWritten)

   The failure also occurs just after writing system while the code is attempting to (prematurely)  "WriteEndObject:, but it also occurs without system and display (with just one contained field, the "code"). So there seems to be two issues: (a) the _isPolymorphic is causing the WriteEndObject to fire too soon instead of reading all contained fields, and (b) the WriteEndObject is confused (?) about the value to write for the Array state.

(2) FhirbaseJsonReader fails to read Medication[x] when it is a Resource.

The json is:
	{
	  "resourceType": "MedicationStatement",
	  "id": "example005",
	  "status": "entered-in-error",	  
	  "medicationCodeableConcept": {
		"coding": [
		  {
			"system": "http://snomed.info/sct",
			"code": "27658006",
			"display": "Amoxicillin (product)"
		  }
		]
	  },
	  "subject": {
		"reference": "Patient/4d5ed44d-ba1d-41b2-866e-5a9662278ae6",
		"display": "Donald Duck"
	  }
	}

The error is thrown by: result.Add(_parser.Parse<T>(reader));
The error is: System.ArgumentException: Can not add Newtonsoft.Json.Linq.JValue to Newtonsoft.Json.Linq.JObject.

Lastly, since we cannot read Medication as CodeableConcept we do not know if the Read would fail, but we suspect it would.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant