use of org.hl7.fhir.dstu3.hapi.ctx.DefaultProfileValidationSupport in project fhir-bridge by ehrbase.
the class FhirValidationConfiguration method validationSupport.
public IValidationSupport validationSupport() {
ValidationSupportChain validationSupportChain = new ValidationSupportChain();
// Validates core structure definitions
DefaultProfileValidationSupport defaultProfileValidationSupport = new DefaultProfileValidationSupport(fhirContext);
defaultProfileValidationSupport.fetchAllStructureDefinitions();
defaultProfileValidationSupport.fetchCodeSystem("");
validationSupportChain.addValidationSupport(defaultProfileValidationSupport);
// Validates custom profiles (loaded from classpath)
PrePopulatedValidationSupport prePopulatedValidationSupport = new PrePopulatedValidationSupport(fhirContext);
IParser parser = fhirContext.newXmlParser();
try {
for (Resource resource : applicationContext.getResources("classpath:/profiles/*")) {
StructureDefinition profile = parser.parseResource(StructureDefinition.class, resource.getInputStream());
if (properties.isOptionalIdentifier()) {
modifyProfile(profile);
}
prePopulatedValidationSupport.addStructureDefinition(profile);
}
} catch (IOException e) {
throw new FhirBridgeException("An I/O exception occurred while loading custom profiles");
}
validationSupportChain.fetchAllStructureDefinitions();
defaultProfileValidationSupport.fetchCodeSystem("");
validationSupportChain.addValidationSupport(prePopulatedValidationSupport);
// Validates terminology: CodeSystems and ValueSets (using the internal and/or remote terminology service)
if (isTerminologyValidationEnabled()) {
TerminologyValidationMode mode = properties.getTerminology().getMode();
if (mode == TerminologyValidationMode.REMOTE || mode == TerminologyValidationMode.MIXED) {
RemoteTerminologyServiceValidationSupport remoteTerminologyServerValidationSupport = new RemoteTerminologyServiceValidationSupport(fhirContext);
remoteTerminologyServerValidationSupport.setBaseUrl(properties.getTerminology().getServerBaseUrl());
validationSupportChain.addValidationSupport(remoteTerminologyServerValidationSupport);
}
if (mode == TerminologyValidationMode.INTERNAL || mode == TerminologyValidationMode.MIXED) {
validationSupportChain.addValidationSupport(new InMemoryTerminologyServerValidationSupport(fhirContext));
validationSupportChain.addValidationSupport(new CommonCodeSystemsTerminologyService(fhirContext));
}
}
return new CachingValidationSupport(validationSupportChain);
}
use of org.hl7.fhir.dstu3.hapi.ctx.DefaultProfileValidationSupport in project dpc-app by CMSgov.
the class RosterValidationTest method setup.
@BeforeAll
static void setup() {
ctx = FhirContext.forDstu3();
final FhirInstanceValidator instanceValidator = new FhirInstanceValidator();
fhirValidator = ctx.newValidator();
fhirValidator.setValidateAgainstStandardSchematron(false);
fhirValidator.setValidateAgainstStandardSchema(false);
fhirValidator.registerValidatorModule(instanceValidator);
dpcModule = new DPCProfileSupport(ctx);
final ValidationSupportChain chain = new ValidationSupportChain(new DefaultProfileValidationSupport(), dpcModule);
instanceValidator.setValidationSupport(chain);
}
use of org.hl7.fhir.dstu3.hapi.ctx.DefaultProfileValidationSupport in project dpc-app by CMSgov.
the class AttestationValidationTest method setup.
@BeforeAll
static void setup() {
ctx = FhirContext.forDstu3();
final FhirInstanceValidator instanceValidator = new FhirInstanceValidator();
fhirValidator = ctx.newValidator();
fhirValidator.setValidateAgainstStandardSchematron(false);
fhirValidator.setValidateAgainstStandardSchema(false);
fhirValidator.registerValidatorModule(instanceValidator);
dpcModule = new DPCProfileSupport(ctx);
final ValidationSupportChain chain = new ValidationSupportChain(new DefaultProfileValidationSupport(), dpcModule);
instanceValidator.setValidationSupport(chain);
}
use of org.hl7.fhir.dstu3.hapi.ctx.DefaultProfileValidationSupport in project dpc-app by CMSgov.
the class OrganizationValidationTest method setup.
@BeforeAll
static void setup() {
ctx = FhirContext.forDstu3();
final FhirInstanceValidator instanceValidator = new FhirInstanceValidator();
fhirValidator = ctx.newValidator();
fhirValidator.setValidateAgainstStandardSchematron(false);
fhirValidator.setValidateAgainstStandardSchema(false);
fhirValidator.registerValidatorModule(instanceValidator);
dpcModule = new DPCProfileSupport(ctx);
final ValidationSupportChain chain = new ValidationSupportChain(new DefaultProfileValidationSupport(), dpcModule);
instanceValidator.setValidationSupport(chain);
}
use of org.hl7.fhir.dstu3.hapi.ctx.DefaultProfileValidationSupport in project synthea by synthetichealth.
the class ValidationResources method initializeSTU3.
private void initializeSTU3() {
FhirContext ctx = FhirStu3.getContext();
FhirInstanceValidator instanceValidator = new FhirInstanceValidator(ctx);
ValidationSupportChain chain = new ValidationSupportChain(new ValidationSupportSTU3(ctx), new DefaultProfileValidationSupport(ctx), new InMemoryTerminologyServerValidationSupport(ctx), new CommonCodeSystemsTerminologyService(ctx));
instanceValidator.setValidationSupport(chain);
instanceValidator.setAnyExtensionsAllowed(true);
instanceValidator.setErrorForUnknownProfiles(false);
validatorSTU3 = ctx.newValidator().registerValidatorModule(instanceValidator);
}
Aggregations