Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
java.lang.ClassCastException: java.lang.String cannot be cast to org.hl7.fhir.instance.model.api.IBase #304
java.lang.ClassCastException: java.lang.String cannot be cast to org.hl7.fhir.instance.model.api.IBase
the stack trace points at:
Looks like somehow the parser is expecting an IBase but is getting a String. It should be no problem with the resource that I am serializing becuase everything was fine during the instantiation process.
In this case we are serializing a Bundle with a MessageHeader and Encounter resources.
Tested on HAPI versions 1.2, 1.3 and 1.4
Meanwhile I found the reason for this error was because of the name property of the patient resource.
It is strange that this does not give an error while setting the name, only while encoding to string...
I don't know exactly the right syntax you'd need, but presumably it would be something like
var name = new Packages.ca.uhn.fhir.model.dstu2.composite.HumanNameDt(); name.addGiven('Hugo'); patient.setName([name]);
I understand the issue with generics... Has an improvement on the parser I think you could control these encoding errors and produce a detailed error message showing exactly wich property is failling during the encoding process.
Keep up the great work.