From 44189e9bde7f121698288f9947952d6cc7c19e6c Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 22 Nov 2024 22:50:42 +1100 Subject: [PATCH 1/4] fix NPE processing issue from template --- .../src/main/java/org/hl7/fhir/r4/utils/ToolingExtensions.java | 3 +++ .../main/java/org/hl7/fhir/r4b/utils/ToolingExtensions.java | 3 +++ .../src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java | 3 +++ 3 files changed, 9 insertions(+) diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/ToolingExtensions.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/ToolingExtensions.java index 73238d879..fcee1c351 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/ToolingExtensions.java @@ -874,6 +874,9 @@ public class ToolingExtensions { } private static IssueSeverity mapSeverity(org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity severity) { + if (severity == null) { + return null; + } switch (severity) { case ERROR: return IssueSeverity.ERROR; diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/ToolingExtensions.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/ToolingExtensions.java index 9923e3aac..837d058fc 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/ToolingExtensions.java @@ -903,6 +903,9 @@ public class ToolingExtensions { } private static IssueSeverity mapSeverity(org.hl7.fhir.r4b.model.OperationOutcome.IssueSeverity severity) { + if (severity == null) { + return null; + } switch (severity) { case ERROR: return IssueSeverity.ERROR; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java index a0604d348..f7bfa3504 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java @@ -1071,6 +1071,9 @@ public class ToolingExtensions { } private static IssueSeverity mapSeverity(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity severity) { + if (severity == null) { + return null; + } switch (severity) { case ERROR: return IssueSeverity.ERROR; case FATAL: return IssueSeverity.FATAL; From aa128248f66e947ecb543b4c695e5d829c501756 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 22 Nov 2024 22:50:59 +1100 Subject: [PATCH 2/4] fix NPE rendering reference --- .../fhir/r5/renderers/ResourceRenderer.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ResourceRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ResourceRenderer.java index 2d99f765a..ba4d22bf4 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ResourceRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ResourceRenderer.java @@ -846,22 +846,26 @@ public abstract class ResourceRenderer extends DataRenderer { if (!Utilities.noString(r.getId())) { if (!context.isSecondaryLang()) { String sid = r.getScopedId(); - if (!context.hasAnchor(sid)) { - context.addAnchor(sid); - x.an(context.prefixAnchor(sid)); - } - sid = "hc"+sid; - if (!context.hasAnchor(sid)) { - context.addAnchor(sid); - x.an(context.prefixAnchor(sid)); + if (sid != null) { + if (!context.hasAnchor(sid)) { + context.addAnchor(sid); + x.an(context.prefixAnchor(sid)); + } + sid = "hc"+sid; + if (!context.hasAnchor(sid)) { + context.addAnchor(sid); + x.an(context.prefixAnchor(sid)); + } } } if (context.getLocale() != null) { String langSuffix = "-"+context.getLocale().toLanguageTag(); - String sid = r.getScopedId()+langSuffix; - if (!context.hasAnchor(sid)) { - context.addAnchor(sid); - x.an(context.prefixAnchor(sid)); + if (r.getScopedId() != null) { + String sid = r.getScopedId()+langSuffix; + if (!context.hasAnchor(sid)) { + context.addAnchor(sid); + x.an(context.prefixAnchor(sid)); + } } } } From ff3e9edf61421023460c2c5e838fa7b8f1791b28 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 22 Nov 2024 22:51:20 +1100 Subject: [PATCH 3/4] Support for Custom resources in publisher --- .../hl7/fhir/utilities/npm/NpmPackage.java | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/NpmPackage.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/NpmPackage.java index 362757650..20b316642 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/NpmPackage.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/NpmPackage.java @@ -331,6 +331,7 @@ public class NpmPackage { } + private String path; private JsonObject npm; private Map folders = new HashMap<>(); @@ -339,6 +340,7 @@ public class NpmPackage { private boolean minimalMemory; private int size; private boolean warned = false; + private static boolean loadCustomResources; /** * Constructor @@ -406,7 +408,7 @@ public class NpmPackage { public void loadFiles(String path, File source, String... exemptions) throws FileNotFoundException, IOException { this.npm = JsonParser.parseObject(TextFile.fileToString(Utilities.path(path, "package", "package.json"))); this.path = path; - + File dir = ManagedFileAccess.file(path); for (File f : dir.listFiles()) { if (!isInternalExemptFile(f) && !Utilities.existsInList(f.getName(), exemptions)) { @@ -431,6 +433,7 @@ public class NpmPackage { } } loadSubFolders(dir.getAbsolutePath(), f); + } else { NpmPackageFolder folder = this.new NpmPackageFolder(Utilities.path("package", "$root")); folder.folder = dir; @@ -448,24 +451,26 @@ public class NpmPackage { private void loadSubFolders(String rootPath, File dir) throws IOException { for (File f : dir.listFiles()) { if (f.isDirectory()) { - String d = f.getAbsolutePath().substring(rootPath.length()+1); - if (!d.startsWith("package")) { - d = Utilities.path("package", d); - } - NpmPackageFolder folder = this.new NpmPackageFolder(d); - folder.folder = f; - this.folders.put(d, folder); - File ij = ManagedFileAccess.file(Utilities.path(f.getAbsolutePath(), ".index.json")); - if (ij.exists() || !minimalMemory) { - try { - if (!ij.exists() || !folder.readIndex(JsonParser.parseObject(ij), folder.getTypes())) { - indexFolder(folder.getFolderName(), folder); - } - } catch (Exception e) { - throw new IOException("Error parsing "+ij.getAbsolutePath()+": "+e.getMessage(), e); + if (!"custom".equals(f.getName()) || loadCustomResources) { + String d = f.getAbsolutePath().substring(rootPath.length()+1); + if (!d.startsWith("package")) { + d = Utilities.path("package", d); } + NpmPackageFolder folder = this.new NpmPackageFolder(d); + folder.folder = f; + this.folders.put(d, folder); + File ij = ManagedFileAccess.file(Utilities.path(f.getAbsolutePath(), ".index.json")); + if (ij.exists() || !minimalMemory) { + try { + if (!ij.exists() || !folder.readIndex(JsonParser.parseObject(ij), folder.getTypes())) { + indexFolder(folder.getFolderName(), folder); + } + } catch (Exception e) { + throw new IOException("Error parsing "+ij.getAbsolutePath()+": "+e.getMessage(), e); + } + } + loadSubFolders(rootPath, f); } - loadSubFolders(rootPath, f); } } } @@ -1510,5 +1515,12 @@ public class NpmPackage { return id()+"#"+version(); } - + public static boolean isLoadCustomResources() { + return loadCustomResources; + } + + public static void setLoadCustomResources(boolean loadCustomResources) { + NpmPackage.loadCustomResources = loadCustomResources; + } + } \ No newline at end of file From 42065d54636962d8f85c02f6d4ae72b22a223d49 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 22 Nov 2024 22:52:46 +1100 Subject: [PATCH 4/4] release notes --- RELEASE_NOTES.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index afe3c1eed..c87116037 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,7 +1,11 @@ ## Validator Changes * fix pattern discriminator validation rule +* fix issue with FHIRPath engine throwing exception for an invalid path ## Other code changes -* no changes \ No newline at end of file +* fix NPE rendering reference +* fix NPE processing issue from template +* Add FeatureDefinition renderer +* Support for Custom resources in publisher