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

hapi-fhir-base-1.0 doesn't support having links in the BundleEntry which is not compliant to the spec #178

Closed
joedai opened this Issue Jun 3, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@joedai

joedai commented Jun 3, 2015

Hi,
We got ca.uhn.fhir.parser.DataFormatException while using the HAPI client to perform a search against the patient resource. In Bundle.entry there is a link which causes the problem. But according to the spec, it is valid to have a link in the entry.

We are using hapi-fhir-base-1.0, and we checked the source code of ca.uhn.fhir.parser.ParserState.BundleEntryState

Seems like it doesn't support having link in the BundleEntry

        @Override
        public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException {
            if ("base".equals(theLocalPart)) {
                push(new PrimitiveState(getPreResourceState(), myEntry.getLinkBase()));
            } else if ("transaction".equals(theLocalPart)) {
                push(new BundleEntryTransactionState(myEntry));
            } else if ("search".equals(theLocalPart)) {
                push(new BundleEntrySearchState(myEntry));
            } else if ("score".equals(theLocalPart)) {
                push(new PrimitiveState(getPreResourceState(), myEntry.getScore()));
            } else if ("resource".equals(theLocalPart)) {
                push(new PreResourceStateHapi(myEntry, myResourceType));
            } else if ("deleted".equals(theLocalPart)) {
                push(new BundleEntryDeletedState(getPreResourceState(), myEntry));
            } else {
                throw new DataFormatException("Unexpected element in entry: " + theLocalPart);
            }

            // TODO: handle category
        }

Error message

ca.uhn.fhir.parser.DataFormatException: DataFormatException at [[row,col {unknown-source}]: [1,347]]: Unexpected element in entry: link
    at ca.uhn.fhir.parser.XmlParser.doXmlLoop(XmlParser.java:211)
    at ca.uhn.fhir.parser.XmlParser.parseBundle(XmlParser.java:987)
    at ca.uhn.fhir.parser.XmlParser.parseBundle(XmlParser.java:982)
    at ca.uhn.fhir.rest.method.BaseResourceReturningMethodBinding.invokeClient(BaseResourceReturningMethodBinding.java:154)
    at ca.uhn.fhir.rest.method.SearchMethodBinding.invokeClient(SearchMethodBinding.java:58)
    at ca.uhn.fhir.rest.client.BaseClient.invokeClient(BaseClient.java:318)
    at ca.uhn.fhir.rest.client.BaseClient.invokeClient(BaseClient.java:153)
    at ca.uhn.fhir.rest.client.BaseClient.invokeClient(BaseClient.java:149)
    at ca.uhn.fhir.rest.client.ClientInvocationHandler.invoke(ClientInvocationHandler.java:63)
Caused by: ca.uhn.fhir.parser.DataFormatException: Unexpected element in entry: link
    at ca.uhn.fhir.parser.ParserState$BundleEntryState.enteringNewElement(ParserState.java:1056)
    at ca.uhn.fhir.parser.ParserState.enteringNewElement(ParserState.java:105)
    at ca.uhn.fhir.parser.XmlParser.doXmlLoop(XmlParser.java:182)
    at ca.uhn.fhir.parser.XmlParser.parseBundle(XmlParser.java:987)
    at ca.uhn.fhir.parser.XmlParser.parseBundle(XmlParser.java:982)
    at ca.uhn.fhir.rest.method.BaseResourceReturningMethodBinding.invokeClient(BaseResourceReturningMethodBinding.java:154)
    at ca.uhn.fhir.rest.method.SearchMethodBinding.invokeClient(SearchMethodBinding.java:58)
    at ca.uhn.fhir.rest.client.BaseClient.invokeClient(BaseClient.java:318)
    at ca.uhn.fhir.rest.client.BaseClient.invokeClient(BaseClient.java:153)
    at ca.uhn.fhir.rest.client.BaseClient.invokeClient(BaseClient.java:149)
    at ca.uhn.fhir.rest.client.ClientInvocationHandler.invoke(ClientInvocationHandler.java:63)

@joedai joedai changed the title from Got DataFormatException while parsing a dstu2 bundle that contains link in the entry to hapi-fhir-base-1.0 doesn't support having links in the BundleEntry which is not compliant to the spec Jun 3, 2015

@jamesagnew

This comment has been minimized.

Owner

jamesagnew commented Jun 4, 2015

Thanks for reporting! Committing a fix now.

Note that you might want to consider using the DSTU2 resource bundle (ca.uhn.fhir.model.dstu2.resource.Bundle) instead of the old DSTU1 atom style bundle (ca.uhn.fhir.model.api.Bundle), as it has better support for DSTU2 features like this one.

@jamesagnew jamesagnew closed this in 8c3c8e2 Jun 4, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment