-
Notifications
You must be signed in to change notification settings - Fork 343
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
The validator is not resolving certain references #1654
Comments
I have made a unit test for it: [Theory]
[InlineData("Issue_1654_medicationstatement.xml", typeof(MedicationStatement))]
[InlineData("Issue_1654_careteam.xml", typeof(CareTeam))]
public void Issue_1654(string testFile, Type pocoType)
{
var client = new FhirClient("https://fhir.simplifier.net/UKCore");
var visitResolver = new VisitResolver();
var resolver = new CachedResolver(new MultiResolver(ZipSource.CreateValidationSource(), visitResolver, new WebResolver(id => client)));
var validator = new Validator(new ValidationSettings() { ResourceResolver = resolver, ResolveExternalReferences = true });
var xml = File.ReadAllText(Path.Combine("TestData", "validation", testFile));
var parser = new FhirXmlParser();
var poco = parser.Parse(xml, pocoType);
Assert.NotNull(poco);
var outcome = validator.Validate(poco);
Assert.True(outcome.Success);
Assert.True(0 == outcome.Warnings, $"Found {outcome.Warnings} warnings in test file {testFile}");
Assert.True(visitResolver.Visited("Patient/UKCore-Patient-RichardSmith-Example"), "example patient has not been resolved");
}
class VisitResolver : IResourceResolver
{
private List<string> _visits = new List<string>();
public Resource ResolveByCanonicalUri(string uri) => null;
public Resource ResolveByUri(string uri)
{
_visits.Add(uri);
return null;
}
internal bool Visited(string uri) => _visits.Contains(uri);
} We see indeed that the MedicationStatement case does not resolve the reference Btw, in the CareTeam instance there is a reference to |
We have found that on our project, validation to resolve references works as expected on non-profiled resources (i.e. if resource.meta.profile is not supplied), but for profiled resources, the validation to resolve references is not executed, and no warnings are generated for broken references. We tested the same message with and without resource.meta.profile using HL7 FHIR Validator, with identical warning messages re: references not locally contained and references unreachable by traversing from the first Bundle entry. Not sure if it's related, but it sounds like a similar issue. |
Describe the bug
We have identified some cases in which the validator is not calling the IResourceResolver to resolve certain relative references.
To Reproduce
Steps to reproduce the behavior:
Both this resources have a reference to
Patient/UKCore-Patient-RichardSmith-Example
:https://simplifier.net/ukcore/ukcore-careteam-weightmanagementteam-example
https://simplifier.net/ukcore/ukcore-medicationstatement-amoxicillin-example
However, validating them the outcome is different:
Our investigation concluded that in the case of the resource that doesn't give warnings the validator is not calling the IResourceResolver to resolve the reference.
Expected behavior
Both validations should attempt to resolve the reference to
Patient/UKCore-Patient-RichardSmith-Example
.Screenshots
If applicable, add screenshots to help explain your problem.
Version used:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: