Search in sources :

Example 1 with ValidationSupportChain

use of org.hl7.fhir.dstu3.hapi.validation.ValidationSupportChain in project ipf by oehf.

the class Iti65Validator method loadStructureDefinitions.

public ValidationSupportChain loadStructureDefinitions(IValidationSupport baseValidationSupport, String kind) {
    var validationSupport = new PrePopulatedValidationSupport(fhirContext);
    var supportChain = new ValidationSupportChain(validationSupport, baseValidationSupport, new InMemoryTerminologyServerValidationSupport(baseValidationSupport.getFhirContext()), new CommonCodeSystemsTerminologyService(baseValidationSupport.getFhirContext()));
    findProfile(supportChain, String.format("IHE_MHD_%s_List", kind)).ifPresent(validationSupport::addStructureDefinition);
    findProfile(supportChain, String.format("IHE_MHD_Provide_%s_DocumentReference", kind)).ifPresent(validationSupport::addStructureDefinition);
    findProfile(supportChain, String.format("IHE_MHD_Query_%s_DocumentReference", kind)).ifPresent(validationSupport::addStructureDefinition);
    findProfile(supportChain, String.format("IHE_MHD_%s_DocumentManifest", kind)).ifPresent(validationSupport::addStructureDefinition);
    findProfile(supportChain, String.format("IHE_MHD_Provide_%s_DocumentBundle", kind)).ifPresent(validationSupport::addStructureDefinition);
    return supportChain;
}
Also used : InMemoryTerminologyServerValidationSupport(org.hl7.fhir.common.hapi.validation.support.InMemoryTerminologyServerValidationSupport) PrePopulatedValidationSupport(org.hl7.fhir.common.hapi.validation.support.PrePopulatedValidationSupport) ValidationSupportChain(org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain) CommonCodeSystemsTerminologyService(org.hl7.fhir.common.hapi.validation.support.CommonCodeSystemsTerminologyService)

Example 2 with ValidationSupportChain

use of org.hl7.fhir.dstu3.hapi.validation.ValidationSupportChain 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);
}
Also used : PrePopulatedValidationSupport(org.hl7.fhir.common.hapi.validation.support.PrePopulatedValidationSupport) RemoteTerminologyServiceValidationSupport(org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport) Resource(org.springframework.core.io.Resource) FhirBridgeException(org.ehrbase.fhirbridge.FhirBridgeException) IOException(java.io.IOException) DefaultProfileValidationSupport(ca.uhn.fhir.context.support.DefaultProfileValidationSupport) CommonCodeSystemsTerminologyService(org.hl7.fhir.common.hapi.validation.support.CommonCodeSystemsTerminologyService) StructureDefinition(org.hl7.fhir.r4.model.StructureDefinition) InMemoryTerminologyServerValidationSupport(org.hl7.fhir.common.hapi.validation.support.InMemoryTerminologyServerValidationSupport) ValidationSupportChain(org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain) TerminologyValidationMode(org.ehrbase.fhirbridge.fhir.common.validation.TerminologyValidationMode) CachingValidationSupport(org.hl7.fhir.common.hapi.validation.support.CachingValidationSupport) IParser(ca.uhn.fhir.parser.IParser)

Example 3 with ValidationSupportChain

use of org.hl7.fhir.dstu3.hapi.validation.ValidationSupportChain 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);
}
Also used : ValidationSupportChain(org.hl7.fhir.dstu3.hapi.validation.ValidationSupportChain) FhirInstanceValidator(org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator) DefaultProfileValidationSupport(org.hl7.fhir.dstu3.hapi.ctx.DefaultProfileValidationSupport) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with ValidationSupportChain

use of org.hl7.fhir.dstu3.hapi.validation.ValidationSupportChain 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);
}
Also used : ValidationSupportChain(org.hl7.fhir.dstu3.hapi.validation.ValidationSupportChain) FhirInstanceValidator(org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator) DefaultProfileValidationSupport(org.hl7.fhir.dstu3.hapi.ctx.DefaultProfileValidationSupport) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with ValidationSupportChain

use of org.hl7.fhir.dstu3.hapi.validation.ValidationSupportChain 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);
}
Also used : ValidationSupportChain(org.hl7.fhir.dstu3.hapi.validation.ValidationSupportChain) FhirInstanceValidator(org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator) DefaultProfileValidationSupport(org.hl7.fhir.dstu3.hapi.ctx.DefaultProfileValidationSupport) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

DefaultProfileValidationSupport (org.hl7.fhir.dstu3.hapi.ctx.DefaultProfileValidationSupport)7 ValidationSupportChain (org.hl7.fhir.dstu3.hapi.validation.ValidationSupportChain)7 FhirInstanceValidator (org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator)6 BeforeAll (org.junit.jupiter.api.BeforeAll)6 CommonCodeSystemsTerminologyService (org.hl7.fhir.common.hapi.validation.support.CommonCodeSystemsTerminologyService)5 InMemoryTerminologyServerValidationSupport (org.hl7.fhir.common.hapi.validation.support.InMemoryTerminologyServerValidationSupport)5 ValidationSupportChain (org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain)5 DefaultProfileValidationSupport (ca.uhn.fhir.context.support.DefaultProfileValidationSupport)3 PrePopulatedValidationSupport (org.hl7.fhir.common.hapi.validation.support.PrePopulatedValidationSupport)3 FhirContext (ca.uhn.fhir.context.FhirContext)2 FhirInstanceValidator (org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator)2 IParser (ca.uhn.fhir.parser.IParser)1 OrganizationPrincipal (gov.cms.dpc.api.auth.OrganizationPrincipal)1 JsonParseExceptionMapper (gov.cms.dpc.api.exceptions.JsonParseExceptionMapper)1 DPCFHIRConfiguration (gov.cms.dpc.fhir.configuration.DPCFHIRConfiguration)1 BundleHandler (gov.cms.dpc.fhir.dropwizard.handlers.BundleHandler)1 FHIRHandler (gov.cms.dpc.fhir.dropwizard.handlers.FHIRHandler)1 HAPIExceptionHandler (gov.cms.dpc.fhir.dropwizard.handlers.exceptions.HAPIExceptionHandler)1 JerseyExceptionHandler (gov.cms.dpc.fhir.dropwizard.handlers.exceptions.JerseyExceptionHandler)1 DPCProfileSupport (gov.cms.dpc.fhir.validations.DPCProfileSupport)1