From 231aae60435a1526afebfe4c78dc8d24dedad9fe Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 14 Nov 2022 18:04:27 +1100 Subject: [PATCH] Fix issue rendering resource by name --- .../r5/renderers/utils/DirectWrappers.java | 20 +++++++++++++++++-- .../hl7/fhir/utilities/npm/NpmPackage.java | 9 +++++++-- .../src/main/resources/Messages.properties | 4 ++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DirectWrappers.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DirectWrappers.java index d89e34c01..a3117b396 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DirectWrappers.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DirectWrappers.java @@ -223,8 +223,24 @@ public class DirectWrappers { s = s + " " + family.getValues().get(0).primitiveValue().toUpperCase(); return s; } else { - // it might be a human name? - throw new Error("What to do? Type is "+b.fhirType()); + Property p = b.getChildByName("name"); + if (p == null || !p.hasValues()) { + p = b.getChildByName("name"); + } + if (p == null || !p.hasValues()) { + p = b.getChildByName("text"); + } + if (p == null || !p.hasValues()) { + p = b.getChildByName("value"); + } + if (p == null || !p.hasValues()) { + p = b.getChildByName("productName"); // MedicinalProductDefinition + } + if (p == null || !p.hasValues()) { + throw new Error("What to render for 'name'? Type is "+b.fhirType()); + } else { + return p.getValues().get(0).primitiveValue(); + } } } return null; 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 7d5a38edd..701709d92 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 @@ -559,7 +559,7 @@ public class NpmPackage { for (JsonElement e : folder.index.getAsJsonArray("files")) { JsonObject fi = e.getAsJsonObject(); if (Utilities.existsInList(JsonUtilities.str(fi, "resourceType"), types)) { - res.add(new PackageResourceInformation(folder.folder.getAbsolutePath(), fi)); + res.add(new PackageResourceInformation(folder.folder == null ? "@"+folder.getName() : folder.folder.getAbsolutePath(), fi)); } } } @@ -1159,7 +1159,12 @@ public class NpmPackage { } public InputStream load(PackageResourceInformation p) throws FileNotFoundException { - return new FileInputStream(p.filename); + if (p.filename.startsWith("@")) { + String[] pl = p.filename.substring(1).split("\\/"); + return new ByteArrayInputStream(folders.get(pl[0]).content.get(pl[1])); + } else { + return new FileInputStream(p.filename); + } } public Date dateAsDate() { diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index 732f591d3..988599ed8 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -550,8 +550,8 @@ SEARCHPARAMETER_EXP_WRONG = The expression ''{2}'' is not compatible with the ex VALUESET_NO_SYSTEM_WARNING = No System specified, so Concepts and Filters can't be checked VALUESET_INCLUDE_INVALID_CONCEPT_CODE = The code {1} is not valid in the system {0} VALUESET_INCLUDE_INVALID_CONCEPT_CODE_VER = The code {2} is not valid in the system {0} version {1} -VALUESET_UNC_SYSTEM_WARNING = Unknown System ''{0}'' specified, so Concepts and Filters can't be checked -VALUESET_UNC_SYSTEM_WARNING_VER = Unknown System/Version ''{0}'' specified, so Concepts and Filters can't be checked +VALUESET_UNC_SYSTEM_WARNING = Unknown System ''{0}'' specified, so Concepts and Filters can''t be checked (Details: {1}) +VALUESET_UNC_SYSTEM_WARNING_VER = Unknown System/Version ''{0}'' specified, so Concepts and Filters can''t be checked (Details: {1}) Extension_PROF_Type = The Profile ''{0}'' definition allows for the type {1} but found type {2} TYPE_CHECKS_PATTERN_CC = The pattern [system {0}, code {1}, and display ''{2}''] defined in the profile {3} not found. Issues: {4} TYPE_CHECKS_PATTERN_CC_US = The pattern [system {0}, code {1}, display ''{2}'' and userSelected {5}] defined in the profile {3} not found. Issues: {4}