I would like to make sure that I can validate a FHIR resource against US-Core profiles.
Where I am stumbling is how to download all the US core profiles into a local directory on my machine so that I can set the path in the CachedResolver
using Hl7.Fhir.Specification.Source;
using Hl7.Fhir.Validation;
// setup the resolver to use specification.zip, and a folder with US Core profiles
var source = new CachedResolver(new MultiResolver(
new DirectorySource(@"<path_to_profile_folder>"),
ZipSource.CreateValidationSource()));
// prepare the settings for the validator
var ctx = new ValidationSettings()
{
ResourceResolver = source,
GenerateSnapshot = true,
Trace = false,
EnableXsdValidation = true,
ResolveExteralReferences = false
}
var validator = new Validator(ctx);
// validate the resource; optionally enter a custom profile url as 2nd parameter
var poco = (new FhirJsonParser()).Parse<Resource>(txtJson);
result = validator.Validate(poco);
Also, do I need to specify a 2nd parameter? Say I need to validate my json using US core AllergyIntolerance profile.
Thank you!