Stream: implementers
Topic: use uuid as resource id
Yunwei Wang (May 26 2019 at 15:13):
when using uuid as resource id, should it be prefixed with 'urn:uuid'? I have seen both and wondering which is "more" correct.
patient.id = '0a76c550-1434-41a1-92fd-65f8fc582a85'
or
patient.id = 'urn:uuid:0a76c550-1434-41a1-92fd-65f8fc582a85'
Lloyd McKenzie (May 26 2019 at 19:11):
First. I don't think colons are allowed in the id type
Justin Hopper (May 26 2019 at 19:19):
the id is its own type distinctly separated from the uuid type, and I believe the very reason for this separation is because the allowed characters within do not support the URI character set, as Lloyd mentioned. the ID is used as the logical identifier in the REST urls (/patient/0a76c550-1434-41a1-92fd-65f8fc582a85), so again it would be strange to see the URI format here (e.g. /patient/urn:uuid:0a76c550-1434-41a1-92fd-65f8fc582a85)
Yunwei Wang (May 26 2019 at 19:49):
@Justin Hopper Yes, I agree that url looks strange. That's one reason I raised this thread
@Lloyd McKenzie Oh. I forgot about that. Looks like that system doesn't apply validation correctly.
René Spronk (May 27 2019 at 06:44):
I have seen /Patient/urn:uuid:0a76c550-1434-41a1-92fd-65f8fc582a85 style URLs in production use, HAPI supports it.
Lloyd McKenzie (May 27 2019 at 13:12):
@James Agnew You shouldn't be allowing this...
James Agnew (May 27 2019 at 13:40):
Ugh, if it's outputting that, that's a bug.
As context though: HAPI has a datatype called IdType (or IdDt in DSTU1/2) that represents the entire fully qualified ID and optionally the version. So it can hold http://foo/Patient/123
or urn:uuid:BLAH-BLA
or #FOO
but in both of those cases it has the getIdPart()
method to pull out the 123
or BLAH-BLA
or FOO
parts.
Patrick Werner recently discovered some flakiness in how it deals with UUIDs, we have an open ticket about that...
Lloyd McKenzie (May 27 2019 at 13:43):
@James Agnew It's also possible someone is using PUT to set the id to that.
James Agnew (May 27 2019 at 13:43):
Oh, and just to add: When an IdType holds urn:uuid:BLAH-BLA
the intent is always that when the patient is serialized you would just see "id":"BLAH-BLA"
. The urn: prefix only shows up in Bundle.entry.fullUrl
when you need an ID that's scoped to the bundle (e.g. for transactions)
James Agnew (May 27 2019 at 13:44):
Now I'm curious if it will let me create such a monstrosity... :)
James Agnew (May 27 2019 at 13:46):
woohoo... well, at least we don't allow that:
<issue>
<severity value="error"/>
<code value="processing"/>
<diagnostics value="Can not process entity with ID[urn:uuid:BLAH-BLA], this is not a valid FHIR ID"/>
</issue>
Last updated: Apr 12 2022 at 19:14 UTC