diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java index e5092d2cc..475d42e1e 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java @@ -10014,6 +10014,57 @@ The primary difference between a medication statement and a medication administr return _4_1_0; throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); } + + public static boolean isValidCode(String codeString) { + if (codeString == null || "".equals(codeString)) + return false; + if ("0.01".equals(codeString)) + return true; + if ("0.05".equals(codeString)) + return true; + if ("0.06".equals(codeString)) + return true; + if ("0.11".equals(codeString)) + return true; + if ("0.0.80".equals(codeString)) + return true; + if ("0.0.81".equals(codeString)) + return true; + if ("0.0.82".equals(codeString)) + return true; + if ("0.4.0".equals(codeString)) + return true; + if ("0.5.0".equals(codeString)) + return true; + if ("1.0.0".equals(codeString)) + return true; + if ("1.0.1".equals(codeString)) + return true; + if ("1.0.2".equals(codeString)) + return true; + if ("1.1.0".equals(codeString)) + return true; + if ("1.4.0".equals(codeString)) + return true; + if ("1.6.0".equals(codeString)) + return true; + if ("1.8.0".equals(codeString)) + return true; + if ("3.0.0".equals(codeString)) + return true; + if ("3.0.1".equals(codeString)) + return true; + if ("3.3.0".equals(codeString)) + return true; + if ("3.5.0".equals(codeString)) + return true; + if ("4.0.0".equals(codeString)) + return true; + if ("4.1.0".equals(codeString)) + return true; + return false; + } + @Override public String toString() { return toCode(); 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 e4548dba7..d1a991c5c 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 @@ -25,6 +25,7 @@ import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.util.ArrayList; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.HashSet; @@ -85,7 +86,18 @@ public class NPMPackageGenerator { System.out.println("create package file at "+destFile); this.destFile = destFile; start(); - buildPackageJson(canonical, kind, url, genDate, ig); + List fhirVersion = new ArrayList<>(); + for (Enumeration v : ig.getFhirVersion()) + fhirVersion.add(v.asStringValue()); + buildPackageJson(canonical, kind, url, genDate, ig, fhirVersion); + } + + public NPMPackageGenerator(String destFile, String canonical, String url, PackageType kind, ImplementationGuide ig, String genDate, List fhirVersion) throws FHIRException, IOException { + super(); + System.out.println("create package file at "+destFile); + this.destFile = destFile; + start(); + buildPackageJson(canonical, kind, url, genDate, ig, fhirVersion); } public NPMPackageGenerator(String destFile, JsonObject npm) throws FHIRException, IOException { @@ -102,7 +114,7 @@ public class NPMPackageGenerator { } - private void buildPackageJson(String canonical, PackageType kind, String web, String genDate, ImplementationGuide ig) throws FHIRException, IOException { + private void buildPackageJson(String canonical, PackageType kind, String web, String genDate, ImplementationGuide ig, List fhirVersion) throws FHIRException, IOException { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); if (!ig.hasPackageId()) b.append("packageId"); @@ -134,8 +146,8 @@ public class NPMPackageGenerator { if (kind != PackageType.CORE) { JsonObject dep = new JsonObject(); npm.add("dependencies", dep); - for (Enumeration v : ig.getFhirVersion()) { // TODO: fix for multiple versions - dep.addProperty("hl7.fhir.core", v.asStringValue()); + for (String v : fhirVersion) { // TODO: fix for multiple versions + dep.addProperty("hl7.fhir.core", v); } for (ImplementationGuideDependsOnComponent d : ig.getDependsOn()) { dep.addProperty(d.getPackageId(), d.getVersion()); diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java index 2337ae85c..79d32b08c 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java @@ -343,5 +343,10 @@ import com.google.gson.JsonObject; } } + /** special case when playing around inside the package **/ + public Map getContent() { + return content; + } + } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java index 9656c8f80..6b1046e94 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java @@ -1,5 +1,7 @@ package org.hl7.fhir.utilities.json; +import java.io.IOException; + /*- * #%L * org.hl7.fhir.utilities @@ -22,12 +24,13 @@ package org.hl7.fhir.utilities.json; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; public class JSONUtil { - public static JsonObject parse(String json) { - return (JsonObject) new com.google.gson.JsonParser().parse(json); + public static JsonObject parse(String json) throws IOException { + return JsonTrackingParser.parseJson(json); } @@ -56,4 +59,13 @@ public class JSONUtil { return res; } + public static JsonObject findByStringProp(JsonArray arr, String prop, String value) { + for (JsonElement e : arr) { + JsonObject obj = (JsonObject) e; + if (obj.has(prop) && obj.get(prop).getAsString().equals(value)) + return obj; + } + return null; + } + } diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java index 421f4a50f..0e5d3b0a5 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java @@ -107,7 +107,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour if (ve == null || !v.equals(veVersion)) { if (v.equals("5.0")) - ve = new ValidationEngine("hl7.fhir.core#4.1.0", DEF_TX, null, FhirPublication.R5); + ve = new ValidationEngine("hl7.fhir.core#current", DEF_TX, null, FhirPublication.R5); else if (v.equals("3.0")) ve = new ValidationEngine("hl7.fhir.core#3.0.1", DEF_TX, null, FhirPublication.STU3); else if (v.equals("4.0")) diff --git a/release.bat b/release.bat index bd48f741f..abe60d8c8 100644 --- a/release.bat +++ b/release.bat @@ -9,31 +9,10 @@ echo =============================================================== pause call mvn versions:set -DnewVersion=3.7.26-SNAPSHOT - -echo =============================================================== -echo upgraded version number using maven -echo next: do git commit / push -echo =============================================================== -pause - call git commit -a -m "Release new version" call git push origin master - -echo =============================================================== -echo done git commit / push -echo next: replace references in java code + ivy -echo =============================================================== -pause - call "C:\tools\fnr.exe" --cl --dir "C:\work\org.hl7.fhir\build" --fileMask "*.java" --excludeFileMask "*.dll, *.exe" --includeSubDirectories --find "3.7.25-SNAPSHOT" --replace "3.7.26-SNAPSHOT" call "C:\tools\fnr.exe" --cl --dir "C:\work\org.hl7.fhir\build" --fileMask "*.xml" --excludeFileMask "*.dll, *.exe" --find "3.7.25-SNAPSHOT" --replace "3.7.26-SNAPSHOT" - -echo =============================================================== -echo done replacing references -echo next: do maven release -echo =============================================================== -pause - call mvn deploy echo ===============================================================