Stream: implementers
Topic: Whitespace in code data type
Cooper Thompson (Mar 05 2020 at 18:49):
Does anyone have any background about why we have this requirement in the definition of the code data type:
Technically, a code is restricted to a string which has at least one character and no leading or trailing whitespace, and where there is no whitespace other than single spaces in the contents.
What is so bad about having multiple spaces in a code? I mean I wouldn't personally create codes with double spaces, but are there real reasons we need to prohibit it?
Cooper Thompson (Mar 05 2020 at 18:53):
J#18441 and J#5573 have some related notes, but nothing that really jumps out as causing a problem with codes with multiple spaces.
Vassil Peytchev (Mar 05 2020 at 18:53):
Applying a digital signature will normalize the white space. Code comparisons/lookup are done using exact match. Things will break. :slight_smile:
Cooper Thompson (Mar 05 2020 at 18:56):
If you are doing code comparisons for a locally defined code set with multiple spaces, then you would get exact matches. It seems really odd that a digital signature normalization would control what content can be expressed.
Lloyd McKenzie (Mar 05 2020 at 19:07):
If someone is authoring codes where the meaning is dependent on the number of consecutive white-space characters, I'd like to meet that individual in a dark alley somewhere...
Gino Canessa (Mar 05 2020 at 19:29):
But, think of the security / privacy benefits! :stuck_out_tongue_wink:
Grahame Grieve (Mar 05 2020 at 20:46):
it's because of tricky issues around whitespace normalization in xml when using schema
Grahame Grieve (Mar 05 2020 at 20:47):
but I agree with Lloyd about multiple spaces in a code. Have you get a practical example?
Cooper Thompson (Mar 06 2020 at 18:31):
We have a framework where organizations can define their own local codes, typically for communication within the hospital system. We ran into a case where it was a typo that triggered our FHIR validation, but it got me looking at the rules for the code data type.
Lloyd McKenzie (Mar 06 2020 at 19:52):
That's one of the benefits of the rules :)
Peter Jordan (Mar 06 2020 at 21:16):
The V3 data types schema contains a Regex check that prevents the use of spaces in codes. In NZ, we ran into this problem in the early days of our national GP2GP system due to one vendor's legacy use of user-defined codes (which, by their very nature, are not interoperable). Fortunately, the CDA payload in this system is generated from a single common component, so we were able to implement a quick fix. I'm guessing that plenty of other countries will encounter this problem when attempting to exchange legacy data at a national level.
Last updated: Apr 12 2022 at 19:14 UTC