From 3e6863ef70e21413c04a61de6c8d2d49cd048b4f Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 1 Oct 2020 11:05:24 +1000 Subject: [PATCH] Support for additional checking in IG Publisher --- RELEASE_NOTES.md | 5 ++++- .../java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java | 6 ++++++ .../hl7/fhir/utilities/CommaSeparatedStringBuilder.java | 9 +++++++++ .../org/hl7/fhir/utilities/json/JsonTrackingParser.java | 9 +++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e97786dae..d773df519 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,7 +1,10 @@ Validator: -* Add date addition/subtraction to FHIRPath +* Add date addition/subtraction to FHIRPath + add parsing comments * Fix questionnaire mode parameter support for validator * add extra debugging when valdiator can't fetch content to validate Other code changes: * rename org.hl7.fhir.utilities.cache to org.hl7.fhir.utilities.npm +* report error locations for run time FHIRPath errors +* add search on IG registry to PackageClient +* add focus to FHIRPath function extensions \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java index 5a8d2fb93..3bbfe0ed3 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java @@ -102,6 +102,7 @@ public class NPMPackageGenerator { private JsonObject packageJ; private JsonObject packageManifest; private NpmPackageIndexBuilder indexer; + private String igVersion; public NPMPackageGenerator(String destFile, String canonical, String url, PackageType kind, ImplementationGuide ig, Date date, boolean notForPublication) throws FHIRException, IOException { @@ -184,6 +185,7 @@ public class NPMPackageGenerator { JsonObject npm = new JsonObject(); npm.addProperty("name", ig.getPackageId()); npm.addProperty("version", ig.getVersion()); + igVersion = ig.getVersion(); npm.addProperty("tools-version", ToolsVersion.TOOLS_VERSION); npm.addProperty("type", kind.getCode()); npm.addProperty("date", dt); @@ -395,5 +397,9 @@ public class NPMPackageGenerator { } } + public String version() { + return igVersion; + } + } \ No newline at end of file diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/CommaSeparatedStringBuilder.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/CommaSeparatedStringBuilder.java index 3973f1506..89c2eec92 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/CommaSeparatedStringBuilder.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/CommaSeparatedStringBuilder.java @@ -1,5 +1,7 @@ package org.hl7.fhir.utilities; +import java.util.List; + /* Copyright (c) 2011+, HL7, Inc. All rights reserved. @@ -76,4 +78,11 @@ public class CommaSeparatedStringBuilder { append(s); } + + public void addAll(List list) { + for (String s : list) { + append(s); + } + + } } \ No newline at end of file diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonTrackingParser.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonTrackingParser.java index e133d2f02..977d6873b 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonTrackingParser.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonTrackingParser.java @@ -36,6 +36,8 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.Map; import java.util.Stack; @@ -671,6 +673,13 @@ public class JsonTrackingParser { Gson gson = new GsonBuilder().setPrettyPrinting().create(); return gson.toJson(json); } + + public static JsonObject fetchJson(String source) throws IOException { + URL url = new URL(source+"?nocache=" + System.currentTimeMillis()); + HttpURLConnection c = (HttpURLConnection) url.openConnection(); + c.setInstanceFollowRedirects(true); + return parseJson(c.getInputStream()); + } } \ No newline at end of file