fhir-net-api(STU3)-正在验证



我一直在使用Hl7.org工具org.Hl7.fhir.validator.jar文件来验证我的消息,但我想将此函数添加到我的.Net项目中。一旦我解析了消息,就可以调用一个类来验证Structure。

在FHIR net api中是否有一个validate FHIR类会显示与org.hl7.FHIR.validator.jar相同的结果?

string HL7FilePath = string.Format("{0}\{1}", System.IO.Directory.GetCurrentDirectory(), "Sample.xml");
string HL7FileData = File.ReadAllText(HL7FilePath)
var b = new FhirXmlParser().Parse<PlanDefinition>(HL7FileData);

FHIR Validator Build ??
Arguments: C:HL7ToolsvalidatorREC78_1.xml -version 3.0
.. connect to tx server @ http://tx.fhir.org
.. definitions from hl7.fhir.core#3.0.1
(v3.0.1-null)
.. validate [C:HL7ToolsvalidatorSample.xml]
Terminology server: Check for supported code systems for http://www.nlm.nih.gov/research/umls/rxnorm
Success.

是的。您需要添加Hl7.Fhir.Specification.STU3包,然后可以使用以下验证方法:

using Hl7.Fhir.Specification.Source;
using Hl7.Fhir.Validation;
... your code, reading the PlanDefinition from file and parsing it ...
// setup the resolver to use specification.zip, and a folder with custom 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 result = validator.Validate(b);

结果将是包含验证详细信息的OperationResult资源。

最新更新