Skip to content

Commit

Permalink
FI-3387: Bump dependencies (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
dehall authored Nov 11, 2024
1 parent c2adc3e commit 6781793
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
11 changes: 7 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ repositories {
}

dependencies {
implementation("ca.uhn.hapi.fhir", "org.hl7.fhir.validation", "6.2.8")
implementation("ca.uhn.hapi.fhir", "org.hl7.fhir.validation", "6.4.0")

// validator dependency needed for terminology (why can't it get this automatically?)
implementation("com.squareup.okhttp3", "okhttp", "4.9.0")
implementation("com.squareup.okhttp3", "okhttp", "4.12.0")

// validator dependency needed to prevent a ClassNotFoundException
implementation("org.fhir:ucum:1.0.8")

// GSON for our JSON needs
implementation("com.google.code.gson", "gson", "2.10.1")
implementation("com.google.code.gson", "gson", "2.11.0")

// Basic logging. Reload4J is a security-focused fork of Log4J 1.x
implementation("org.slf4j", "slf4j-reload4j", "2.0.7")
implementation("org.slf4j", "slf4j-reload4j", "2.0.16")

// Web Server
implementation("com.sparkjava", "spark-core", "2.9.4")
Expand Down
32 changes: 27 additions & 5 deletions src/main/java/org/mitre/inferno/Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.npm.PackageClient;
import org.hl7.fhir.utilities.npm.PackageInfo;
import org.hl7.fhir.utilities.npm.PackageServer;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.validation.BaseValidator;
import org.hl7.fhir.validation.BaseValidator.ValidationControl;
Expand Down Expand Up @@ -68,12 +71,14 @@ public Validator(String igDir, boolean displayIssuesAreWarnings) throws Exceptio
final String txServer = getTxServerUrl();
final String txLog = null;
final String fhirVersion = "4.0.1";
final boolean useEcosystem = true;

ValidationEngineBuilder engineBuilder =
new ValidationEngineBuilder().withTxServer(
txServer,
txLog,
FhirPublication.fromCode(fhirVersion)
FhirPublication.fromCode(fhirVersion),
useEcosystem
);
hl7Validator = engineBuilder.fromSource(definitions);

Expand Down Expand Up @@ -103,7 +108,8 @@ public Validator(String igDir, boolean displayIssuesAreWarnings) throws Exceptio
}
}

hl7Validator.connectToTSServer(txServer, txLog, FhirPublication.fromCode(fhirVersion));
hl7Validator.connectToTSServer(
txServer, txLog, FhirPublication.fromCode(fhirVersion), useEcosystem);
hl7Validator.setDoNative(false);
hl7Validator.setAnyExtensionsAllowed(true);
hl7Validator.setDisplayWarnings(displayIssuesAreWarnings);
Expand Down Expand Up @@ -210,11 +216,27 @@ public Map<String, String> getKnownIGs() throws IOException {
String canonical = e.getValue().canonical();
igs.put(id, canonical);
}
// Add IGs known to the package manager, replacing any conflicting package IDs
packageManager.listAllIds(igs);
// Add IGs known to the package manager
for (PackageServer next : packageManager.getPackageServers()) {
// https://github.com/hapifhir/org.hl7.fhir.core/blob/6.2.8/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java#L585
listSpecs(igs, next);
}

return igs;
}

// copied from
// https://github.com/hapifhir/org.hl7.fhir.core/blob/6.2.8/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java#L318
private void listSpecs(Map<String, String> specList, PackageServer server) throws IOException {
PackageClient pc = new PackageClient(server);
List<PackageInfo> matches = pc.search(null, null, null, false);
for (PackageInfo m : matches) {
if (!specList.containsKey(m.getId())) {
specList.put(m.getId(), m.getUrl());
}
}
}

/**
* Load a profile into the validator.
*
Expand All @@ -229,7 +251,7 @@ public void loadProfile(byte[] profile) throws IOException {
LOGGER.info("Loaded profile from file, url: " + sd.getUrl() + " version: " + sd.getVersion());
} else if (resource != null) {
LOGGER.info("Loaded resource from file but it wasn't a StructureDefinition, it was a "
+ resource.fhirType());
+ resource.fhirType());
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/mitre/inferno/ValidatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,19 @@ void getKnownIGs() throws IOException {

@Test
void loadIg() throws Exception {
// A small subset of the profiles in mCODE 3.0.0
// A small subset of the profiles in mCODE 4.0.0
List<String> profilesToLoad = Arrays.asList(
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-disease-status",
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-patient",
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-related-medication-request",
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-related-surgical-procedure",
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-stage-group"
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-stage"
);
assertTrue(profilesToLoad.stream().noneMatch(this::isProfileLoaded));

// Because the version isn't given, this should load the "current" version of hl7.fhir.us.mcode
// Note this means that if a new version is published that changes the profile names
// (as has happened in updates 1->2 and 2->3) this test may fail
// (as has happened in updates 1->2, 2->3, and 3->4) this test may fail
IgResponse ig = validator.loadIg("hl7.fhir.us.mcode", null);
assertEquals("hl7.fhir.us.mcode", ig.id);
assertTrue(ig.profiles.containsAll(profilesToLoad));
Expand Down

0 comments on commit 6781793

Please sign in to comment.