in javaHapiValidatorLambda/src/main/java/software/amazon/fwoa/Validator.java [77:108]
public Validator(String fhirVersion, String implementationGuidesFolder) {
if (!Objects.equals(fhirVersion, FHIR_R4) && !Objects.equals(fhirVersion, FHIR_STU3)) {
throw new RuntimeException("Invalid FHIR version " + fhirVersion);
}
this.fhirVersion = fhirVersion;
this.implementationGuidesFolder = implementationGuidesFolder;
// To learn more about the different ways to configure FhirInstanceValidator see: https://hapifhir.io/hapi-fhir/docs/validation/validation_support_modules.html
ctx = FHIR_R4.equals(fhirVersion) ? FhirContext.forR4() : FhirContext.forDstu3();
// Create a chain that will hold our modules
ValidationSupportChain supportChain = new ValidationSupportChain();
// DefaultProfileValidationSupport supplies base FHIR definitions. This is generally required
// even if you are using custom profiles, since those profiles will derive from the base
// definitions.
DefaultProfileValidationSupport defaultSupport = new DefaultProfileValidationSupport(ctx);
supportChain.addValidationSupport(defaultSupport);
// This module supplies several code systems that are commonly used in validation
supportChain.addValidationSupport(new CommonCodeSystemsTerminologyService(ctx));
// This module implements terminology services for in-memory code validation
supportChain.addValidationSupport(new InMemoryTerminologyServerValidationSupport(ctx));
// Create a PrePopulatedValidationSupport which can be used to load custom definitions.
PrePopulatedValidationSupport prepopulatedValidationSupport = loadIgs(ctx);
supportChain.addValidationSupport(prepopulatedValidationSupport);
// Create a validator using the FhirInstanceValidator module.
FhirInstanceValidator validatorModule = new FhirInstanceValidator(supportChain);
validator = ctx.newValidator().registerValidatorModule(validatorModule);
}