Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using resolve() function in slicing discriminator path results in "Internal logic failure: Unknown symbol 'resolve'" #263

Closed
cames-be opened this issue Dec 21, 2023 · 3 comments
Assignees

Comments

@cames-be
Copy link

Describe the bug
When validating a resource using the Hl7.Fhir.Validation.Legacy Validator, if the slicing discrimator path uses the resolve() function an error of Internal logic failure: Unknown symbol 'resolve' will be returned in the OperationOutcome.

To Reproduce
Steps to reproduce the behavior:

  1. Using the IG Publisher, create a new Appointment.fsh file with the following profile to generate a package.tgz file (see the attached StructureDefinition-TestAppointment.json for SD output):
Profile: TestAppointment
Title: "Appointment"
Parent: Appointment
Description: "Appointment blah blah blah."

* participant ^slicing.discriminator.type = #type
* participant ^slicing.discriminator.path = "$this.actor.resolve()"
* participant ^slicing.rules = #open
* participant contains Patient 1..1
* participant[Patient] ^short = "Patient involved in appointment"
* participant[Patient].actor only Reference(Patient)
* participant[Patient].actor ^short = "Reference to Patient"
* participant[Patient].status ^short = "Status not used"
  1. Use the following code to reproduce the error
const string pathToPackageTgz = "/pathto/package.tgz";

FhirPackageSource sourceResolver = new FhirPackageSource(ModelInfo.ModelInspector, new[] { pathToPackageTgz });
MultiResolver resolver = new MultiResolver(sourceResolver, ZipSource.CreateValidationSource());

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

FhirPathCompiler compiler = new FhirPathCompiler(symbolTable);

ValidationSettings settings = new ValidationSettings()
{
    FhirPathCompiler = compiler,
    ResourceResolver = resolver
};

Validator validator = new Validator(settings);

Appointment appointment = new Appointment()
{
    Contained = new List<Resource>()
    {
        new Patient()
        {
            Id = "pat1",
            Name = new List<HumanName>() { new HumanName() { Family = "given" } }
        }
    },
    Status = Appointment.AppointmentStatus.Proposed,
    Participant = new List<Appointment.ParticipantComponent>()
    {
        new Appointment.ParticipantComponent()
        {
            Actor = new ResourceReference()
            {
                Reference = "#pat1",
                Type = "Patient"
            },
            Status = ParticipationStatus.Accepted
        }
    }
};

OperationOutcome oo = validator.Validate(appointment.ToTypedElement(), new[] { "http://fhir.myawesomesite.net/StructureDefinition/TestAppointment" });

Expected behavior
Validation should succeed as the slice discriminator should resolve to the contained Patient resource.

Version used:

  • FHIR Version: R4 and R5
  • Version: Hl7.Fhir.Validation.Legacy 5.1 and firely-net-sdk 5.1

Additional context

It appears even with a provided FhirPathCompiler with the SymbolTable.AddFhirExtensions() extension function called, the provided compiler isn't used and a default FhirPathCompiler is used with only the standard SymbolTable. The provided FhirPathCompiler has 155 entries in the SymbolTable and when the exception about the missing symbol is thrown there are only 150 entries in the SymbolTable being used. Looking through the stack, it appears that the FhirPathCompilerCache only uses a FhirPathCompiler with the default SymbolTable.

When evaluating the discriminator, the stack follows:

Examining how the cache is loaded, it uses compiler: null which will then in the FhirPathCompilerCache constructor use the DefaultSymbolTable.

As a test I modified the FhirPathCompilerCache to use new FhirPathCompiler(FhirPathCompiler.DefaultSymbolTable.AddFhirExtensions()) which resulted in the resolve() function being used and the validation succeeded. (Note, I'm not suggesting changing the SymbolTable in the cache, just showing how I was able to get successful validation)

@barbrovessman
Copy link

barbrovessman commented Jan 17, 2024

This error does not occur with the new validator, but there are still problems detecting the slices. See https://chat.fhir.org/#narrow/stream/179171-dotnet/topic/Validator.2E.20Internal.20logic.20failure.3A.20Unknown.20symbol.20'resolve'/near/415986587

@ewoutkramer
Copy link
Member

Ok, thanks for the update.

@ewoutkramer ewoutkramer transferred this issue from FirelyTeam/firely-net-sdk Jan 22, 2024
@mmsmits mmsmits assigned mmsmits and ewoutkramer and unassigned mmsmits Feb 21, 2024
@mmsmits
Copy link
Member

mmsmits commented Apr 25, 2024

I see this was resolved in the new validator and a ticket (#261) was created for the slices not being detected.

@mmsmits mmsmits closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants