
001package org.hl7.fhir.common.hapi.validation.support; 002 003import ca.uhn.fhir.context.ConfigurationException; 004import ca.uhn.fhir.context.FhirContext; 005import ca.uhn.fhir.context.FhirVersionEnum; 006import ca.uhn.fhir.i18n.Msg; 007import ca.uhn.fhir.util.Logs; 008import ca.uhn.fhir.util.StopWatch; 009import jakarta.annotation.Nonnull; 010import org.apache.commons.lang3.Validate; 011import org.slf4j.Logger; 012 013import java.io.IOException; 014 015// This is instantiated through reflection from DefaultProfileValidationSupport 016@SuppressWarnings("unused") 017public class DefaultProfileValidationSupportNpmStrategy extends NpmPackageValidationSupport { 018 private static final Logger ourLog = Logs.getTerminologyTroubleshootingLog(); 019 020 /** 021 * Constructor 022 */ 023 public DefaultProfileValidationSupportNpmStrategy(@Nonnull FhirContext theFhirContext) { 024 super(theFhirContext); 025 026 Validate.isTrue(theFhirContext.getVersion().getVersion() == FhirVersionEnum.R5); 027 028 ourLog.info("Loading R5 Core+Extension packages into memory"); 029 StopWatch sw = new StopWatch(); 030 031 try { 032 loadPackageFromClasspath("org/hl7/fhir/r5/packages/hl7.fhir.r5.core-5.0.0.tgz"); 033 loadPackageFromClasspath("org/hl7/fhir/r5/packages/hl7.fhir.uv.extensions.r5-1.0.0.tgz"); 034 loadPackageFromClasspath("org/hl7/fhir/r5/packages/hl7.terminology-5.1.0.tgz"); 035 } catch (IOException e) { 036 throw new ConfigurationException( 037 Msg.code(2333) 038 + "Failed to load required validation resources. Make sure that the appropriate hapi-fhir-validation-resources-VER JAR is on the classpath", 039 e); 040 } 041 042 ourLog.info("Loaded {} Core+Extension resources in {}", countAll(), sw); 043 } 044 045 @Override 046 public String getName() { 047 return getFhirContext().getVersion().getVersion() + " FHIR Standard Profile NPM Validation Support"; 048 } 049}