FirelyTeam / firely-net-sdk

The official Firely .NET SDK for HL7 FHIR
Other
822 stars 342 forks source link

Is resolve() function supported? #679

Closed jackliums closed 6 years ago

jackliums commented 6 years ago

Hi there,

As part of the issue discussed here, I've updated the expression to use the resolve() function but it seems like the library does not currently support it? When I try to evaluate the expression, it throws the following exception:

ArgumentException: Unknown symbol 'resolve'
Hl7.FhirPath.Expressions.EvaluatorVisitor.resolve(SymbolTable scope, string name, IEnumerable<Type> argumentTypes)

The expression it's trying to evaluate is:

Appointment.participant.actor.where(resolve() is Location)
brianpos commented 6 years ago

Yes we haven't updated it yet. In my server I plan to shortcut it to only process the reference itself, and not read the resource for performance reasons.

ewoutkramer commented 6 years ago

But the question is about resolve(), which we have built in, but it's a FHIR-specific function (FhirPath is used more generally than just within FHIR) so make sure you use a symbol table that is initialized with the FHIR-specific functions. You could either use the extension methods like Select() coming from the Hl7.Fhir.[DSTU].Core libraries or create your own compiler like so:

   var symbolTable = new SymbolTable();
   symbolTable.AddStandardFP();
   symbolTable.AddFhirExtensions();

   var fpCompiler = new FhirPathCompiler(symbolTable);
   // do stuff
jackliums commented 6 years ago

I am using Select() extension methods from the Core libraries and that was the exception I was getting.