From 8870521fb02c4621337b59f36fe962ec832a432e Mon Sep 17 00:00:00 2001 From: Tuncay Namli Date: Thu, 21 Nov 2024 09:39:45 +0300 Subject: [PATCH] :bugs: fix: Fix FHIR path resolve function to at least distinguish simple case of canonical vs literal reference when a simple string is given --- .../scala/io/onfhir/path/FhirPathFunctionEvaluator.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/onfhir-path/src/main/scala/io/onfhir/path/FhirPathFunctionEvaluator.scala b/onfhir-path/src/main/scala/io/onfhir/path/FhirPathFunctionEvaluator.scala index 6c25e9d..ef7ff7a 100644 --- a/onfhir-path/src/main/scala/io/onfhir/path/FhirPathFunctionEvaluator.scala +++ b/onfhir-path/src/main/scala/io/onfhir/path/FhirPathFunctionEvaluator.scala @@ -1,5 +1,6 @@ package io.onfhir.path +import io.onfhir.api.model.FhirLiteralReference import io.onfhir.api.util.FHIRUtil import io.onfhir.path.annotation.FhirPathFunction import io.onfhir.path.grammar.FhirPathExprParser.ExpressionContext @@ -76,7 +77,11 @@ class FhirPathFunctionEvaluator(context: FhirPathEnvironment, current: Seq[FhirP insertText = "resolve()", detail = "", label = "resolve", kind = "Method", returnType = Seq(), inputType = Seq()) def resolve(): Seq[FhirPathResult] = { val fhirReferences = current.map { - case FhirPathString(uri) => FHIRUtil.parseCanonicalReference(uri) + //TODO We cannot distinguish every case if it is string, so we may come up with a new reference type that may be both and resolve can handle that + case FhirPathString(uri) if uri.startsWith("http") => FHIRUtil.parseCanonicalReference(uri) + case FhirPathString(reference) => + val parsedReference = FHIRUtil.parseReferenceValue(reference) + FhirLiteralReference(parsedReference._1, parsedReference._2, parsedReference._3, parsedReference._4) case FhirPathComplex(o) => FHIRUtil.parseReference(o) case _ => throw new FhirPathException("Invalid function call 'resolve', it should be called on a canonical value or FHIR reference!") }