Stream: terminology
Topic: Custom CodeSystem/ValueSet using regex
Richard Ettema (May 12 2021 at 20:11):
I have a question about defining a custom CodeSystem where I want the corresponding ValueSet to allow code values based on a regex expression. For example, I would like to allow for code values that match the following regex - "code\\([1-9][0-9]*\\)".
Would the following CodeSystem and ValueSet correctly define and allow for these types of codes?
CodeSystem using regex
ValueSet using regex
David Pyke (May 12 2021 at 21:13):
I'm not sure I understand. You're trying to create a custom ValueSet from a custom CodeSystem using a regex to define which codes go into the ValueSet?
Richard Ettema (May 12 2021 at 21:19):
Correct. My goal is to support coded values based on the regex. In this example, the following coded values would be valid: "code(1)", "code(14)". The following coded values would be invalid: "code()", "code(a)".
Just wondering if this is possible (seems so from what I can see in the FHIR CodeSystem and ValueSet definitions) and, if possible, is this the correct way of defining it.
John Moehrke (May 12 2021 at 21:22):
seems more like a string than a code
John Moehrke (May 12 2021 at 21:23):
seems to me codes need to have a distinct meaning. so what is the distinct meaning of each of these indexes.
Richard Ettema (May 12 2021 at 21:27):
My goal is to add the CodeSystem to an existing ValueSet so it can be used as a coded value.
The concept would be that the index would be a positive integer value representing a number of iterations for the 'code'.
Richard Ettema (May 12 2021 at 21:30):
I am trying to avoid defining an extension for this index value as I believe this regex code would be more elegant and less verbose than an extension.
David Pyke (May 12 2021 at 21:39):
regex is a valid filter operator in a ValueSet, so assuming the receiving system implemented that, you should be good.
Richard Ettema (May 12 2021 at 21:43):
@David Pyke, thanks for the confirmation. Yes, my receiving system will understand the regex coded value - as soon as I implement it. ;-)
Michael Lawley (May 12 2021 at 21:44):
Your CodeSystem contains no codes
Michael Lawley (May 12 2021 at 21:45):
If you want the regex to match against codes themselves, then the filter should be defined on the concept
property
Michael Lawley (May 12 2021 at 21:47):
...or the code
property - need to check the spec but I'm on the run just now
Richard Ettema (May 12 2021 at 21:50):
CodeSystem.filter is defined at the same level as CodeSystem.concept.
CodeSystem.concept does not define a nested 'filter' and CodeSystem.concept is an optional element.
I guess I'm trying to understand how the CodeSystem.filter with operator = 'regex' works in relation to the ValueSet that includes that CodeSystem.
David Pyke (May 12 2021 at 21:52):
CodeSystem.filter selects codes from a parent CodeSystem (via whatever operatior) and would present them as a list to the ValueSet. The ValueSet would have no idea how they were selected
David Pyke (May 12 2021 at 21:54):
If you're subsetting a custom codesystem, you would list the individual codes there and then use the regex in the ValueSet to select what codes you wanted.
David Pyke (May 12 2021 at 21:55):
The CodeSystem and ValueSet operators work independently of each other
Richard Ettema (May 12 2021 at 21:56):
Ok. Got it. So it sounds like what I would like (dynamically defined coded values via a regex without an explicit list of codes) isn't the intent of the filter or something that is supported.
I'm now guessing that an extension is the more appropriate approach to represent what I want.
David Pyke (May 12 2021 at 21:57):
No, you can't create codes via regex. An extension is what you want
Richard Ettema (May 12 2021 at 21:58):
Thanks! I have my path forward now. :+1:
Lloyd McKenzie (May 12 2021 at 22:31):
We've talked about having a regex defined for code systems so that a code system that doesn't explicitly list code values could still expose a basic set of rules that describe what valid codes look like - e.g. a LOINC code being nnnn-n
Lloyd McKenzie (May 12 2021 at 22:31):
However, you don't seem to have a 'concept' with defined meaning here?
Michael Lawley (May 12 2021 at 22:49):
CodeSystem.filter does NOT select codes from a parent CodeSystem. It defines the existence of a filter that can be used in ValueSets to select a subset of codes from the CodeSystem. There is no notion of a "parent" CodeSystem in FHIR.
Bob Milius (May 13 2021 at 20:15):
I thought grammars can be used as code systems. e.g., The Sequence Variant Nomenclature aka HGVS is described in http://varnomen.hgvs.org and is listed as a code system in https://www.hl7.org/fhir/terminologies-systems.html
Grahame Grieve (May 13 2021 at 20:37):
yes they can
Last updated: Apr 12 2022 at 19:14 UTC