Stream: IG creation
Topic: regular expressions
Bob Milius (Mar 19 2020 at 14:31):
I need to require an Observation I'm profiling to constrain valueCodeableConcept touse a specific code system and a code that is actually a grammar for which I have a rough regular expression I can use as a first pass validation. I know I can use patternCodeableConcept or create a slice to constrain the code system, but I'm not sure how to constrain the code to the regex. I see I can use a regex with matches() in a fhirpath (http://hl7.org/fhirpath/#matchesregex-string-boolean) but not sure how to use it. Maybe invariant? I'd love to see an example if this is possible.
Noemi Deppenwiese (Mar 19 2020 at 14:40):
Not a CodeableConcept, but one of my profiles has an Identifier slice with fixed system and a regex for the value:
{
"id": "Organization.identifier:Bbmri-EricId.system",
"path": "Organization.identifier.system",
"fixedUri": "http://www.bbmri-eric.eu/",
"mustSupport": true
},
{
"id": "Organization.identifier:Bbmri-EricId.value",
"path": "Organization.identifier.value",
"constraint": [
{
"key": "bbmri-id-1",
"requirements": "Make sure valid BBMRI IDs are provided",
"severity": "warning",
"human": "<CC>_<local id>: SHALL contain valid ISO-3166-1 alpha 2 country code followed by _ followed by biobank ID of national registry (if present).",
"expression": "matches('^([a-z]){2}_([a-zA-Z\\\\d])+$')",
"source": "Organization"
}
],
"mustSupport": true
},
Mark Kramer (Mar 19 2020 at 14:56):
@ Bob Milius If you are doing this in FHIR Shorthand, it would be (not yet available, but it will be in the next release):
Invariant: bbmri-id-1
Description: "Make sure valid BBMRI IDs are provided"
Expression: "matches('^([a-z]){2}_([a-zA-Z\\\\d])+$')"
Severity: #warning
Then in the profile:
* identifier.value obeys bbmri-id-1
Bob Milius (Mar 19 2020 at 15:11):
Thanks @Noemi Deppenwiese and @Mark Kramer
Mark, I'll continue with my questions about FSH and regex in the shorthand stream
Last updated: Apr 12 2022 at 19:14 UTC