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

DateTimeDt parsing issue #350

ykovbtc opened this Issue Apr 26, 2016 · 2 comments


None yet
2 participants

ykovbtc commented Apr 26, 2016

The DateTimeDt field is lost during parse operation.

WARN c.u.fhir.parser.LenientErrorHandler [] - Unknown element 'abatement' found while parsing

There is a unit test for

@ResourceDef(name="Condition", profile="", id="custom-condition")
    public static class CustomCondition extends Condition {
        @Child(name = "abatement", min = 0, max = 1, order = Child.REPLACE_PARENT, type = {DateTimeDt.class}, summary = true)
        private DateTimeDt ourAbatement;

        public DateTimeDt getOurAbatement() {
            return ourAbatement;

        void setOurAbatement(DateTimeDt ourAbatement) {
            this.ourAbatement = ourAbatement;

    public void testEncodeAndParseDateTimeDt() {
        FhirContext myCtx = FhirContext.forDstu2();
        myCtx.setDefaultTypeForProfile("", CustomCondition.class);
        IParser parser = myCtx.newXmlParser();

        CustomCondition condition = new CustomCondition();
        condition.setOurAbatement(new DateTimeDt(new Date()));

        String conditionXml = parser.encodeResourceToString(condition);
        CustomCondition parsedCondition = (CustomCondition) parser.parseResource(conditionXml);

This comment has been minimized.

ykovbtc commented Apr 27, 2016

works if I use IDatatype instead of DateTimeDt in field declaration section

@Child(name = "abatement", min = 0, max = 1, order = Child.REPLACE_PARENT, type = {DateTimeDt.class}, summary = true)
        private IDatatype ourAbatement;

This comment has been minimized.


jamesagnew commented Apr 28, 2016

Ahh interesting. If you use a more specific datatype (DateTimeDt) than the parent field (IDatatype) then HAPI "forgets" that this is a choice type and emits the wrong attribute name when serializing (abatement instead of abatementDateTime).

Thanks for reporting! This is an easy fix, should have something checked in within the next day or so.

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