FHIR Chat · Unable to resolve reference to profile · dotnet

Stream: dotnet

Topic: Unable to resolve reference to profile


view this post on Zulip Jeff Chen (Feb 17 2020 at 04:11):

Hi all, I used validate the resource with the profile.
But errors shown below:

{"Overall result: FAILURE (2 errors and 0 warnings)\r\n\r\n
[ERROR] Unable to resolve reference to profile 'http://hl7.org/fhir/StructureDefinition/Observation' (at Observation)\r\n
[ERROR] Unable to resolve reference to profile 'http://hl7.org/fhir/vitalsigns.profile.json' (at Observation)

How do I fix it ?
Thanks!

view this post on Zulip Marco Visser (Feb 17 2020 at 07:13):

It looks like the validator misses the FHIR profiles. You can add them to your resolver like this:

IResourceResolver coreResolver = ZipSource.CreateValidationSource();
var ctx = new ValidationSettings()
            {
                ResourceResolver = coreResolver,
                GenerateSnapshot = true,
                EnableXsdValidation = true,
                Trace = false,
                ResolveExternalReferences = true
            };

var validator = new Validator(ctx);

var outcome = validator.Validate(yourInstance);

view this post on Zulip Jeff Chen (Feb 17 2020 at 08:35):

@Marco Visser May I only put DirectorySource and WebResolver in CachedResolver?
like:

var resolver = new CachedResolver(new MultiResolver(
                new WebResolver(),
                new DirectorySource(@"[my_profile_position]", new DirectorySourceSettings { IncludeSubDirectories = true })
            ));

Thanks !

view this post on Zulip Jeff Chen (Feb 18 2020 at 03:02):

UPDATE
Finally, I only used "ZipSource" as @Marco Visser said
(i used R4 version)

NOTE: "ZipSource.CreateValidationSource()" did not work because specification.zip path was wrong !!
My path specification.zip is "[my_dotnet_project]\packages\Hl7.Fhir.Specification.R4.1.5.0\contentFiles\any\any\specification.zip"

IResourceResolver coreResolver = new ZipSource("[my_dotnet_project]\packages\Hl7.Fhir.Specification.R4.1.5.0\contentFiles\any\any\specification.zip")
var ctx = new ValidationSettings()
            {
                ResourceResolver = coreResolver,
                GenerateSnapshot = true,
                EnableXsdValidation = true,
                Trace = false,
                ResolveExternalReferences = true
            };

var validator = new Validator(ctx);

var outcome = validator.Validate(yourInstance);

everything works fine :)


Last updated: Apr 12 2022 at 19:14 UTC