Skip to content

Commit

Permalink
✨ feat: Enable 'not' modifier for URI search parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuncay NAMLI committed Nov 17, 2021
1 parent 352276c commit 142be0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ object FHIRSearchParameterValueParser {
override def dataType:Parser[String] = uri | boolean | code

/* Prefixes and Suffixes for URI type */
override def suffixes:Parser[String] = """(:(missing|below|above))|$""".r ^^ {_.toString}
override def suffixes:Parser[String] = """(:(missing|below|above|not))|$""".r ^^ {_.toString}
override def prefixes:Parser[String] = """""".r

def parseUriName:Parser[(String, String)] = parseName
Expand Down
24 changes: 14 additions & 10 deletions onfhir-core/src/main/scala/io/onfhir/db/PrefixModifierHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -267,18 +267,22 @@ object PrefixModifierHandler {
val regularExpressionValue = FHIRUtil.escapeCharacters(uri) + "("+ FHIRUtil.escapeCharacters("/")+".*)*"
// Match at the beginning of the uri
regex(path, "\\A" + regularExpressionValue + "$")
case "" =>
case _ =>
//If this is a query on Canonical URLs of the conformance and knowledge resources (e.g. StructureDefinition, ValueSet, PlanDefinition etc) and a version part is given |[version]
if(path == "url" && uri.contains("|")){
val canonicalRef = Try(FHIRUtil.parseCanonicalReference(uri)).toOption
if(canonicalRef.exists(_.version.isDefined))
and(equal(path, canonicalRef.get.getUrl()), equal("version", canonicalRef.get.version.get))
else
var finalQuery =
if(path == "url" && uri.contains("|")){
val canonicalRef = Try(FHIRUtil.parseCanonicalReference(uri)).toOption
if(canonicalRef.exists(_.version.isDefined))
and(equal(path, canonicalRef.get.getUrl()), equal("version", canonicalRef.get.version.get))
else
equal(path, uri)
} else {
// Exact match
equal(path, uri)
} else {
// Exact match
equal(path, uri)
}
}
if(modifier == FHIR_PREFIXES_MODIFIERS.NOT)
finalQuery = not(finalQuery)
finalQuery
case other =>
throw new InvalidParameterException(s"Modifier $other is not supported for FHIR uri queries!")
}
Expand Down

0 comments on commit 142be0f

Please sign in to comment.