FHIR Chat · Question about setting resource ID for create · implementers

Stream: implementers

Topic: Question about setting resource ID for create


view this post on Zulip Anthony Sute (Jun 22 2016 at 16:25):

I'm using HAPI 1.4 and am unable to pass a Patient's or Contract's resource id that I set in the client to the server. The resource id at the server side is always being shown as NULL. Everything else I set in the resource (i.e., identifiers, contained resources, etc) at the client side is being passed through correctly. My code snippet is below:

        Patient pat = new Patient();
        pat.addName().addFamily("SMITH").addGiven("ANDREW");
        pat.setId(new IdDt("hello"));

        // SSN
        pat.addIdentifier().setSystem(uriPrefix + "2.16.840.1.113883.4.1").setValue("123-45-6789");

        pat.setGender(AdministrativeGenderEnum.MALE);

...

Similar code for setting a Contract resource exhibits the same behavior. Is this expected?

view this post on Zulip Ioana Singureanu (Jun 22 2016 at 18:53):

Hi Anthony, I assume this @James Agnew might be able to clarify the HAPI 1.4 implementation. As far as the resource logical id is concerned, the spec does imply that "server that stores the resource" is always responsible for creating the logical id. The API should probably give you some warning if your client is passing a data element (Patient.id) that is not supposed. It appears to be ignoring the id set by client.

view this post on Zulip James Agnew (Jun 22 2016 at 19:59):

Setting the ID on a create is actually not allowed, per FHIR's rules. HAPI's client is trying to be helpful here by not sending the ID since it would be invalid.

If you want to create something but supply the ID yourself, that's still an update according to FHIR's rules so you can do that with the HAPI client's update() method.

view this post on Zulip Anthony Sute (Jun 22 2016 at 22:36):

Thanks James for the clarification.


Last updated: Apr 12 2022 at 19:14 UTC