Invalid Resource id

1,341 views
Skip to first unread message

Marco Strauch

unread,
Jun 17, 2022, 9:29:06 AM6/17/22
to HAPI FHIR
Hi,

i am new to HAPI FHIR and now I tried to validate a resource during update request.

But I got follow error from validator: "Invalid Resource id"

The reason for that error is that my resource id has an underline within the string.
Sample: "AYFxv_azElaa2XFDxfbM".

The resource ID element is only a string so I cannot understand why the parser checks this ID and why it don't accepts the underline in the ID value.
  
In the FHIR specification the id element is only a string and for that underlines are allowed.

So how can I disable this check?

(I am using HAPI FHIR Version 5.7.0)

Regards,
Marco 

Ruth Berge

unread,
Jun 17, 2022, 10:31:23 AM6/17/22
to HAPI FHIR

Just looking at FHIR,  the definition of a resource id is not just "string". it is "A logical id SHALL always be represented in the same way in resource references and URLs. Ids can be up to 64 characters long, and contain any combination of upper and lowercase ASCII letters, numerals, "-" and "."."

Your resource id is not valid.

Marco Strauch

unread,
Jun 20, 2022, 2:00:42 AM6/20/22
to HAPI FHIR
Hi,

Thanks. I found the text for this restriction:

Logical ids (and therefore locations) are case sensitive. Logical Ids are always opaque, and external systems need not and should not attempt to determine their internal structure. A logical id SHALL always be represented in the same way in resource references and URLs. Ids can be up to 64 characters long, and contain any combination of upper and lowercase ASCII letters, numerals, "-" and ".".

But I think this is in conflict with other descriptions of fhir.

Within the documentation for Resource.id (https://www.hl7.org/fhir/resource-definitions.html#Resource.id) the id is explained as follows

Resource.id
Definition: The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
Cardinality: 0..1
Typestring

So it is a type of string. And string must match follow regular expression:  [ \r\n\t\S]+
This expression includes underscores.

My problem is that I use an id generation which generates the id as an URL safe Base64 string. (http://www.faqs.org/rfcs/rfc3548.html). This kind of Base64 allows underscores to replace other non url safe signs.
So I really don't recognize why underscore is forbidden as Resource.id but for URLs this would be safe. Is there a technical reason why forbidding this?

Reagrds,

Marco

Patrick Werner

unread,
Jun 20, 2022, 3:33:02 AM6/20/22
to Marco Strauch, HAPI FHIR
Hi Marco,

Setting Resource.id to String was done by mistake in FHIR R4. See the R4 build:https://hl7.org/fhir/2020Feb/resource.html

cheers
Patrick

-- 
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/1d60aea5-9d7d-41c8-b4d1-5c037cfe22d5n%40googlegroups.com.

Marco Strauch

unread,
Jun 20, 2022, 3:49:53 AM6/20/22
to HAPI FHIR
Ah ok. Thank you. That clears that up.

Regards 
Marco

Reply all
Reply to author
Forward
0 new messages