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

DataFormatException: Unknown resource name "identifier" (this name is not known in FHIR version "DSTU2") #426

Closed
randm-ch opened this Issue Aug 16, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@randm-ch

randm-ch commented Aug 16, 2016

Recently we updated from version 0.8 (DSTU1) to 1.6 (DSTU2). Everything seems to work as expected, except that our integration tests fail.

We use the Play! Framework to route the requests coming to our server and respond with the requested FHIR XML. As already stated, this works well, but when we run tests (with the fakeApplication feature of Play!) this exception occurs:

[error] Test ch.bluecare.patstamm.frontend.controllers.PatientControllerTest.testSearchByActive failed: ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException: Failed to parse response from server when performing GET to URL http://localhost:3333/v1/507f191e810c19729de860ea/Patient?active=false&_format=xml - ca.uhn.fhir.parser.DataFormatException: DataFormatException at [[row,col {unknown-source}]: [1,1078]]: Unknown resource name "identifier" (this name is not known in FHIR version "DSTU2"), took 1.472 sec
[error]     at ca.uhn.fhir.rest.client.BaseClient.invokeClient(BaseClient.java:359)
[error]     at ca.uhn.fhir.rest.client.GenericClient$BaseClientExecutable.invoke(GenericClient.java:717)
[error]     at ca.uhn.fhir.rest.client.GenericClient$SearchInternal.execute(GenericClient.java:1999)
[error]     at ca.uhn.fhir.rest.client.GenericClient$SearchInternal.execute(GenericClient.java:1841)
[error]     at ch.bluecare.patstamm.frontend.controllers.PatientControllerTest.lambda$testSearchByActive$34(PatientControllerTest.java:661)
[error]     at play.test.Helpers.running(Helpers.java:530)
[error]     at ch.bluecare.patstamm.frontend.controllers.PatientControllerTest.testSearchByActive(PatientControllerTest.java:629)
[error]     ...
[error] Caused by: ca.uhn.fhir.parser.DataFormatException: DataFormatException at [[row,col {unknown-source}]: [1,1078]]: Unknown resource name "identifier" (this name is not known in FHIR version "DSTU2")
[error]     at ca.uhn.fhir.parser.XmlParser.doXmlLoop(XmlParser.java:268)
[error]     at ca.uhn.fhir.parser.XmlParser.parseResource(XmlParser.java:1046)
[error]     at ca.uhn.fhir.parser.XmlParser.doParseResource(XmlParser.java:187)
[error]     at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:604)
[error]     at ca.uhn.fhir.rest.client.BaseClient$ResourceResponseHandler.invokeClient(BaseClient.java:534)
[error]     at ca.uhn.fhir.rest.client.BaseClient$ResourceResponseHandler.invokeClient(BaseClient.java:486)
[error]     at ca.uhn.fhir.rest.client.BaseClient.invokeClient(BaseClient.java:352)
[error]     ... 42 more
[error] Caused by: ca.uhn.fhir.parser.DataFormatException: Unknown resource name "identifier" (this name is not known in FHIR version "DSTU2")
[error]     at ca.uhn.fhir.context.FhirContext.getResourceDefinition(FhirContext.java:354)
[error]     at ca.uhn.fhir.context.FhirContext.getResourceDefinition(FhirContext.java:304)
[error]     at ca.uhn.fhir.parser.ParserState$PreResourceState.enteringNewElement(ParserState.java:2015)
[error]     at ca.uhn.fhir.parser.ParserState.enteringNewElement(ParserState.java:137)
[error]     at ca.uhn.fhir.parser.XmlParser.doXmlLoop(XmlParser.java:220)
[error]     ... 48 more

The corresponding line in the test class is the execute() statement in this code:

Bundle response = FhirContext.forDstu2().newRestfulGenericClient(baseUri).search()
        .forResource(PatientResource.class)
        .where(ca.uhn.fhir.model.dstu2.resource.Patient.ACTIVE.exactly().code("false"))
        .encodedXml()
        .returnBundle(Bundle.class)
        .execute();

Any help would be greatly appreciated :-)

@jamesagnew

This comment has been minimized.

Show comment
Hide comment
@jamesagnew

jamesagnew Aug 23, 2016

Owner

Hi @randm-ch, That exception means that the client is failing to parse the response it gets back from the server, but it's not clear to me why it would be failing to do that.

Can you try adding a logging interceptor to the client per the instructions here to see what it's actually getting back? That might shed some light on what's going wrong.

Owner

jamesagnew commented Aug 23, 2016

Hi @randm-ch, That exception means that the client is failing to parse the response it gets back from the server, but it's not clear to me why it would be failing to do that.

Can you try adding a logging interceptor to the client per the instructions here to see what it's actually getting back? That might shed some light on what's going wrong.

@randm-ch

This comment has been minimized.

Show comment
Hide comment
@randm-ch

randm-ch Aug 25, 2016

Hello @jamesagnew
Here is the response XML. It actually looks good to me. Do you see anything wrong with it?

<Bundle xmlns="http://hl7.org/fhir">
    <meta>
        <lastUpdated value="2016-08-25T10:15:53.361+02:00"/>
    </meta>
    <total value="1"/>
    <link>
        <relation value="first"/>
        <url value="http://localhost:3333/v1/507f191e810c19729de860ea/Patient?active=false&amp;_format=xml&amp;page=1"/>
    </link>
    <link>
        <relation value="last"/>
        <url value="http://localhost:3333/v1/507f191e810c19729de860ea/Patient?active=false&amp;_format=xml&amp;page=1"/>
    </link>
    <link>
        <relation value="self"/>
        <url value="http://localhost:3333/v1/507f191e810c19729de860ea/Patient?active=false&amp;_format=xml&amp;page=1"/>
    </link>
    <entry>
        <resource>
            <Patient xmlns="http://hl7.org/fhir">
                <id value="57bea938a7c8aa63e94e4a3c"/>
                <meta>
                    <lastUpdated value="2016-08-25T10:15:52.198+02:00"/>
                    <profile value="http://hl7.org/fhir/profiles/Patient"/>
                </meta>
                <extension url="http://aaa.ch/fhir/Patient#mangedcare">
                    <extension url="http://aaa.ch/fhir/Patient#mangedcare-aaa-id">
                        <valueId value="mc1"/>
                    </extension>
                    <modifierExtension url="http://aaa.ch/fhir/Patient#mangedcare-aaa-status">
                        <valueBoolean value="true"/>
                    </modifierExtension>
                </extension>
                <identifier>
                    <use value="secondary"/>
                    <system value="http://www.aaa.ch/standards/aisid"/>
                    <value value="ais111"/>
                </identifier>
                <identifier>
                    <use value="official"/>
                    <system value="http://www.aaa.ch/standards/patients"/>
                    <value value="57bea938a7c8aa63e94e4a3c"/>
                </identifier>
                <active value="false"/>
                <name>
                    <family value="Müller"/>
                    <given value="Hans"/>
                </name>
                <gender value="male"/>
                <birthDate value="1931-08-01"/>
                <address>
                    <text value="Hans  Müller&#xa;Somestreet 104&#xa; Zürich&#xa;"/>
                    <line value="Somestreet 104"/>
                    <city value="Zürich"/>
                </address>
            </Patient>
        </resource>
    </entry>
</Bundle>

The original is unformatted, of course. The error in my first post would correspond to the first identifier line in this XML. Thanks for taking time with this :)

Cheers!

randm-ch commented Aug 25, 2016

Hello @jamesagnew
Here is the response XML. It actually looks good to me. Do you see anything wrong with it?

<Bundle xmlns="http://hl7.org/fhir">
    <meta>
        <lastUpdated value="2016-08-25T10:15:53.361+02:00"/>
    </meta>
    <total value="1"/>
    <link>
        <relation value="first"/>
        <url value="http://localhost:3333/v1/507f191e810c19729de860ea/Patient?active=false&amp;_format=xml&amp;page=1"/>
    </link>
    <link>
        <relation value="last"/>
        <url value="http://localhost:3333/v1/507f191e810c19729de860ea/Patient?active=false&amp;_format=xml&amp;page=1"/>
    </link>
    <link>
        <relation value="self"/>
        <url value="http://localhost:3333/v1/507f191e810c19729de860ea/Patient?active=false&amp;_format=xml&amp;page=1"/>
    </link>
    <entry>
        <resource>
            <Patient xmlns="http://hl7.org/fhir">
                <id value="57bea938a7c8aa63e94e4a3c"/>
                <meta>
                    <lastUpdated value="2016-08-25T10:15:52.198+02:00"/>
                    <profile value="http://hl7.org/fhir/profiles/Patient"/>
                </meta>
                <extension url="http://aaa.ch/fhir/Patient#mangedcare">
                    <extension url="http://aaa.ch/fhir/Patient#mangedcare-aaa-id">
                        <valueId value="mc1"/>
                    </extension>
                    <modifierExtension url="http://aaa.ch/fhir/Patient#mangedcare-aaa-status">
                        <valueBoolean value="true"/>
                    </modifierExtension>
                </extension>
                <identifier>
                    <use value="secondary"/>
                    <system value="http://www.aaa.ch/standards/aisid"/>
                    <value value="ais111"/>
                </identifier>
                <identifier>
                    <use value="official"/>
                    <system value="http://www.aaa.ch/standards/patients"/>
                    <value value="57bea938a7c8aa63e94e4a3c"/>
                </identifier>
                <active value="false"/>
                <name>
                    <family value="Müller"/>
                    <given value="Hans"/>
                </name>
                <gender value="male"/>
                <birthDate value="1931-08-01"/>
                <address>
                    <text value="Hans  Müller&#xa;Somestreet 104&#xa; Zürich&#xa;"/>
                    <line value="Somestreet 104"/>
                    <city value="Zürich"/>
                </address>
            </Patient>
        </resource>
    </entry>
</Bundle>

The original is unformatted, of course. The error in my first post would correspond to the first identifier line in this XML. Thanks for taking time with this :)

Cheers!

@jamesagnew

This comment has been minimized.

Show comment
Hide comment
@jamesagnew

jamesagnew Aug 25, 2016

Owner

Hi Raphael, I had a look an this looks like it's a bug in HAPI's parser. It appears that HAPI doesn't like extensions with a value type of "id" and that's causing the parser to fail in a weird way.

I'm doing to fix that now. FWIW you could work around this by using a different datatype in the http://aaa.ch/fhir/Patient#mangedcare-aaa-id extension, but you shouldn't have to of course.

Owner

jamesagnew commented Aug 25, 2016

Hi Raphael, I had a look an this looks like it's a bug in HAPI's parser. It appears that HAPI doesn't like extensions with a value type of "id" and that's causing the parser to fail in a weird way.

I'm doing to fix that now. FWIW you could work around this by using a different datatype in the http://aaa.ch/fhir/Patient#mangedcare-aaa-id extension, but you shouldn't have to of course.

@randm-ch

This comment has been minimized.

Show comment
Hide comment
@randm-ch

randm-ch Aug 25, 2016

That's great news! Thanks! 👍

randm-ch commented Aug 25, 2016

That's great news! Thanks! 👍

@randm-ch

This comment has been minimized.

Show comment
Hide comment
@randm-ch

randm-ch Aug 29, 2016

I built the project from master and added the JAR file to my managed dependencies, the fix works. Thanks again! :)

randm-ch commented Aug 29, 2016

I built the project from master and added the JAR file to my managed dependencies, the fix works. Thanks again! :)

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