Stream: fhirpath
Topic: FHIRPath .matches() with linebreaks
Pieter Edelman (May 14 2021 at 06:37):
(previously posted in #implementers ):
Hi,
I'm trying to use the .matches()
FHIRPath function to check if the StructureDefintion.purpose
text is properly populated in some of our profiles. This works as long as I don't include linebreaks in the .purpose
field. If I do, I get inconsistent results. Take the following synthetic example:
-- snip --
<description value="An anatomical location specifies the location (e.g. foot) and laterality (e.g. links) of a bodypart." />
<purpose value="A
B" />
<fhirVersion value="4.0.1" />
-- snip --
Yields:
HL7 Validator | FHIRPath Tester | |
---|---|---|
StructureDefinition.purpose.matches('A.*') |
false | true |
StructureDefinition.purpose.matches('A.*B') |
false | false |
However, the specification states that regexes in matches()
are considered to use single-line mode, suggesting that a dot should match newlines. Could anybody help out?
Lloyd McKenzie (May 14 2021 at 14:11):
@Bryn Rhodes @Grahame Grieve
Pieter Edelman (May 14 2021 at 14:38):
I think the issue is actually an omission in the implementations. I just raised an issue for the FHIR Validator.
Grahame Grieve (May 14 2021 at 21:12):
the test cases are here: https://github.com/FHIR/fhir-test-cases/blob/master/r5/fhirpath/tests-fhir-r5.xml. Do you want to add a test case that fails?
Pieter Edelman (May 17 2021 at 06:56):
Thanks for the pointer, I'll add the test case.
Pieter Edelman (May 17 2021 at 11:39):
@Grahame Grieve I'm not very familiar with Maven, but I believe I managed to add a test case for this issue (not pushed yet). Do you want me to add other test cases for matches()
as well while I'm at it?
Grahame Grieve (May 17 2021 at 19:41):
sure. the more the better
Pieter Edelman (May 18 2021 at 06:56):
Ok, created a pull request
Last updated: Apr 12 2022 at 19:14 UTC