Unable to Validate against a package with Fhir.NET SDK

Hello Folks,
I’m unable to get the FHIR Validator availabel with the FHIR.NET SDK to work in validating against the US Core profile. I’m just starting to use the SDK for validation so I’m likely doing something stupid.

I Downloaded the US CORE Package and have it both in zipped and unzipped form present in folder “fhir-profiles”. However while trying to resolve I get the following errors from OerationOutcome:

  1. Unable to resolve reference to profile ‘…/StructureDefinition/Patient’ (removed full hyperlink to conform to forum rules)
  2. Unable to resolve reference to profile ‘…/StructureDefinition-us-core-patient’ (removed full hyperlink to conform to forum rules)

Any pointers would be appreciated.

Code Snippet

// Tried these combinations for source
/ var source = new CachedResolver(new MultiResolver(
new DirectorySource(@"…/fhir-profiles",
new DirectorySourceSettings() { IncludeSubDirectories = true }),
ZipSource.CreateValidationSource()));
/

var source = new CachedResolver(
new DirectorySource(@"…/fhir-profiles",
new DirectorySourceSettings() { IncludeSubDirectories = true }));

var ctx = new ValidationSettings
{
ResourceResolver = source,
GenerateSnapshot = true,
Trace = false,
// EnableXsdValidation = true, // Tried both combinations
// ResolveExternalReferences = false // Tried both combinations
};

var poco = GetPatientPoco(…);
var validator = new Validator(ctx);

var result = validator.Validate(poco, @“http://hl7.org/fhir/us/core/StructureDefinition-us-core-patient”);
return result;

You are on the right track, but the main thing that trips up the validation is the URL you have used for the US-core patient profile. It should have a ‘/’ instead of a ‘-’ between the type and the name: “http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient”.

You will also need the regular FHIR specification files, so always do use the MultiResolver with the ValidationSource which you have commented out at this time.

When you change those two things, you should see a better result from the validator.

1 Like

Thanks a lot for getting back Mirjam on 3 separate threads of the same question!)! Appreciate it.

With the URL fix you suggested I’m no longer getting the resolution error with the US Core profile.

However after using the multi-resolve I’m getting the error:

Resolution of profile at 'http://hl7.org/fhir/StructureDefinition/Patient' failed: While building a POCO: Literal '3.0.2' is not a valid value for enumeration 'FHIRVersion' (at StructureDefinition.fhirVersion[0])

Inspecting the POCO or it’s de-derialized form, I don’t see any reference to '3.0.2` or FHIR version. Am I using the wrong base specifications for FHIR?